diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-14 15:40:27 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-02-14 15:40:27 +0200 |
| commit | 83ee3f34b630b06f3bcd58f519dea203f8925012 (patch) | |
| tree | b17132099441096592decf5e500e23abf369e9e1 /test | |
| parent | 073d72120acba3de05184f747630bf7a3641a049 (diff) | |
Fix projectile-root-top-down to search top-down, not bottom-up (#1729)
projectile-root-top-down used projectile-locate-dominating-file which
stops at the first (bottommost) match going up the directory tree.
This made it behave identically to projectile-root-bottom-up.
Add projectile-locate-dominating-file-top-down which walks the entire
directory hierarchy and returns the topmost match. For example, with
nested Makefiles at both project/ and project/subdir/, searching from
project/subdir/ now correctly returns project/ instead of
project/subdir/.
Diffstat (limited to 'test')
| -rw-r--r-- | test/projectile-test.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index 2d828bd..2c97762 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -682,6 +682,8 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. "projectA/src/framework/lib/" "projectA/src/framework.conf" "projectA/src/html/index.html") + ;; .git is a directory, so it's not matched by top-down (file markers only); + ;; framework.conf at projectA/src/ is the only match (expect (projectile-root-top-down "projectA/src/framework/lib" '("framework.conf" ".git")) :to-equal (expand-file-name "projectA/src/")) @@ -691,6 +693,15 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. (expect (projectile-root-top-down "projectA/src/html/" '("index.html")) :to-equal (expand-file-name "projectA/src/html/"))))) + (it "returns the topmost match when file markers exist at multiple levels" + (projectile-test-with-sandbox + (projectile-test-with-files + ("project/Makefile" + "project/subdir/Makefile" + "project/subdir/file.txt") + (expect (projectile-root-top-down "project/subdir" '("Makefile")) + :to-equal + (expand-file-name "project/"))))) (it "does not match directories for file-type markers" (projectile-test-with-sandbox (projectile-test-with-files |
