branch: elpa/projectile
commit 155ff835f142f7cd79afb25f0c8828c68d93fedd
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Fix projectile-search crash on the backend name symbol [Fix #2094]
    
    projectile-search passes the backend name (a symbol like `grep') to
    projectile--search-tool-tag, which called `propertize' on it directly -
    and propertize needs a string, so the command errored with
    `wrong-type-argument stringp grep' since 3.2.0.
    
    Format the tool through `%s' so the tag helper accepts either a symbol
    (projectile-search) or a string (grep/ag/ripgrep and the reviewable
    search all pass strings). Note the tempting `symbol-name' fix would flip
    the bug onto the string callers.
---
 CHANGELOG.md                   |  4 ++++
 projectile.el                  | 10 ++++++----
 test/projectile-search-test.el | 16 ++++++++++++++++
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 291c03987b..41f769d325 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 ## master (unreleased)
 
+### Bugs fixed
+
+* [#2094](https://github.com/bbatsov/projectile/issues/2094): Fix a 
`wrong-type-argument stringp` crash when running `projectile-search` (a 3.2.0 
regression): the search-prompt tool tag now accepts the backend name symbol, 
not just a string.
+
 ## 3.2.0 (2026-07-12)
 
 ### New features
diff --git a/projectile.el b/projectile.el
index 2c44c9f83f..42db26436a 100644
--- a/projectile.el
+++ b/projectile.el
@@ -7035,10 +7035,12 @@ This is a subset of `grep-read-files', where either a 
matching entry from
 
 (defun projectile--search-tool-tag (tool)
   "Return a faced `[TOOL]' tag for a search prompt.
-Used where the backend varies (e.g. `projectile-search' or the
-reviewable search's ripgrep/elisp fast-path) so the prompt makes clear
-which tool will run."
-  (format "[%s]" (propertize tool 'face 'projectile-search-prompt-tool)))
+TOOL is the backend, given as a symbol or a string: `projectile-search'
+passes the backend name symbol while the reviewable search passes a
+\"ripgrep\"/\"elisp\" string.  Used where the backend varies so the
+prompt makes clear which tool will run."
+  (format "[%s]" (propertize (format "%s" tool)
+                             'face 'projectile-search-prompt-tool)))
 
 (defun projectile--read-search-string-with-default (prompt-label)
   "Read a search string, defaulting to the symbol or region at point.
diff --git a/test/projectile-search-test.el b/test/projectile-search-test.el
index 397f5e359a..9f4ad986d6 100644
--- a/test/projectile-search-test.el
+++ b/test/projectile-search-test.el
@@ -95,6 +95,22 @@
       (expect (get-text-property 1 'face tag)
               :to-equal 'projectile-search-prompt-tool)))
 
+  (it "accepts a backend name symbol as well as a string (#2094)"
+    ;; `projectile-search' passes the backend symbol, not a string
+    (expect (projectile--search-tool-tag 'grep) :to-equal "[grep]"))
+
+  (it "projectile-search builds its prompt without erroring on the backend 
symbol (#2094)"
+    (spy-on 'projectile-acquire-root :and-return-value "/proj/")
+    (spy-on 'projectile-prepend-project-name :and-call-fake #'identity)
+    (let (prompt
+          (projectile-search-backends
+           (list (cons 'grep (list :search (lambda (&rest _) nil)))))
+          (projectile-search-backend 'grep))
+      (spy-on 'read-string :and-call-fake (lambda (p &rest _) (setq prompt p) 
"foo"))
+      ;; term nil -> the interactive prompt path that used to crash
+      (projectile-search nil nil)
+      (expect prompt :to-match (regexp-quote "[grep]"))))
+
   (describe "projectile--read-search-string-with-default"
     (before-each
       (spy-on 'projectile-prepend-project-name :and-call-fake #'identity))

Reply via email to