aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 18:23:47 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-03-10 10:56:03 +0200
commit0bf326a4a421f1aed9a23a923e5ee799f33480cb (patch)
tree29c5ed62676d18032dc1bc4cd6631fce93e65564
parent02859277e6aed175012c0af551ac4d7a44b92f05 (diff)
Filter projectile-replace results through project ignore rules
Closes #1227 projectile-replace now intersects the files found by rg/ag/grep with the project's file list from projectile-dir-files, ensuring that files ignored via .projectile or other ignore rules are excluded from replacement. Previously the external search tool's results were used directly, which could include backup files and other ignored entries.
-rw-r--r--projectile.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/projectile.el b/projectile.el
index c0591d5..aedc66d 100644
--- a/projectile.el
+++ b/projectile.el
@@ -5040,8 +5040,13 @@ on which to run the replacement."
(new-text (read-string
(projectile-prepend-project-name
(format "Replace %s with: " old-text))))
- (files (projectile-files-with-string old-text directory file-ext)))
- (fileloop-initialize-replace (regexp-quote old-text) new-text files 'default)
+ (files (projectile-files-with-string old-text directory file-ext))
+ ;; Filter results through the project's file list so that files
+ ;; ignored via .projectile or other ignore rules are excluded.
+ (project-files (mapcar (lambda (file) (expand-file-name file directory))
+ (projectile-dir-files directory)))
+ (filtered-files (seq-filter (lambda (f) (member f project-files)) files)))
+ (fileloop-initialize-replace (regexp-quote old-text) new-text filtered-files 'default)
(fileloop-continue)))
;;;###autoload