aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 18:26:35 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 18:26:35 +0200
commit6cef316e0ae19112f30326c78ac004d430062ac3 (patch)
tree0bb4871cbc944603833e4ef0d80c9f9c7a8359a1 /projectile.el
parentdd06dfd912656d41f2c63066aa8bacb898ddf7a2 (diff)
Fix compilation-find-file advice for dirs without direct filesfeature/1923-compilation-search-path
Fixes #1923 When compilation output references a file via a relative path, the advice now also checks if the file exists relative to the project root and adds its parent directory to the search path. This handles the edge case where a directory only contains subdirectories (no files directly) and therefore was not included in the file-derived directory list from projectile-current-project-dirs.
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/projectile.el b/projectile.el
index 6c5306b..479c5e7 100644
--- a/projectile.el
+++ b/projectile.el
@@ -5619,16 +5619,25 @@ We enhance its functionality by appending the current project's directories
to its search path. This way when filenames in compilation buffers can't be
found by compilation's normal logic they are searched for in project
directories."
- ; If the file already exists, don't bother running the extra logic as the project directories might be massive (i.e. Unreal-sized).
+ ;; If the file already exists, don't bother running the extra logic as the
+ ;; project directories might be massive (i.e. Unreal-sized).
(if (file-exists-p filename)
(apply orig-fun `(,marker ,filename ,directory ,@formats))
(let* ((root (projectile-project-root))
(compilation-search-path
(if (projectile-project-p)
- (append compilation-search-path (list root)
- (mapcar (lambda (f) (expand-file-name f root))
- (projectile-current-project-dirs)))
+ (let ((dirs (append compilation-search-path (list root)
+ (mapcar (lambda (f) (expand-file-name f root))
+ (projectile-current-project-dirs)))))
+ ;; If the file can be found relative to the project root,
+ ;; add its parent directory to the search path. This
+ ;; handles directories that contain only subdirectories
+ ;; and no files directly.
+ (let ((candidate (expand-file-name filename root)))
+ (when (file-exists-p candidate)
+ (push (file-name-directory candidate) dirs)))
+ dirs)
compilation-search-path)))
(apply orig-fun `(,marker ,filename ,directory ,@formats)))))