Skip to content

Commit bc61f8a

Browse files
Troy Figielbbatsov
authored andcommitted
[Fix #1962] Fix finding other file when candidate is a root file
1 parent b553164 commit bc61f8a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

projectile.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,8 @@ With FLEX-MATCHING, match any file that contains the base name of current file"
23932393
(candidates
23942394
(cl-sort (copy-sequence candidates)
23952395
(lambda (file _)
2396-
(let ((candidate-dirname (file-name-nondirectory (directory-file-name (file-name-directory file)))))
2396+
(let ((candidate-dirname (file-name-nondirectory (directory-file-name (if (file-name-directory file)
2397+
(file-name-directory file) "./")))))
23972398
(unless (equal fulldirname (file-name-directory file))
23982399
(equal dirname candidate-dirname)))))))
23992400
candidates))

test/projectile-test.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,10 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
11431143
(it "returns files with same names but different extensions"
11441144
(projectile-test-with-sandbox
11451145
(projectile-test-with-files-using-custom-project
1146-
("src/test1.c"
1146+
("root.c"
1147+
"root.h"
1148+
"src/root.h"
1149+
"src/test1.c"
11471150
"src/test2.c"
11481151
"src/test+copying.m"
11491152
"src/test1.cpp"
@@ -1153,6 +1156,7 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
11531156
"src/test.frag"
11541157
"src/same_name.c"
11551158
"src/some_module/same_name.c"
1159+
"include1/root.h"
11561160
"include1/same_name.h"
11571161
"include1/test1.h"
11581162
"include1/test1.h~"
@@ -1196,6 +1200,7 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
11961200
;; handle files with nested extensions
11971201
("service.js" . ("service.spec.js"))
11981202
("js" . ("js")))))
1203+
(expect (projectile-get-other-files "root.c") :to-equal '("root.h" "include1/root.h" "src/root.h"))
11991204
(expect (projectile-get-other-files "src/test1.c") :to-equal '("include1/test1.h" "include2/test1.h"))
12001205
(expect (projectile-get-other-files "src/test1.cpp") :to-equal '("include1/test1.h" "include2/test1.h" "include1/test1.hpp"))
12011206
(expect (projectile-get-other-files "test2.c") :to-equal '("include1/test2.h" "include2/test2.h"))

0 commit comments

Comments
 (0)