Skip to content

Commit

Permalink
Fix search-default-mode lookup in swiper-isearch
Browse files Browse the repository at this point in the history
* swiper.el (swiper--normalize-regex): Look up search-default-mode
where swiper-isearch was called from, not in the minibuffer.

Fixes #3026.
  • Loading branch information
basil-conto committed Oct 25, 2023
1 parent a650bda commit c66769d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions swiper.el
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,21 @@ When capture groups are present in the input, print them instead of lines."
(evil-set-jump)))

(defun swiper--normalize-regex (re)
"Normalize the swiper regex RE.
Add a space after a leading `^' if needed and apply
`search-default-mode' if bound."
"Normalize the Swiper regexp RE.
Add a space after a leading `^' for `swiper', and apply
`search-default-mode' if bound in the original buffer."
(replace-regexp-in-string
"^\\(?:\\\\(\\)?\\^"
(concat "\\&" (if (eq 'swiper (ivy-state-caller ivy-last)) " " ""))
(if (functionp (bound-and-true-p search-default-mode))
(mapconcat
(lambda (x)
(if (string-match-p "\\`[^$\\^]+\\'" x)
(funcall search-default-mode x)
x))
(split-string re "\\b") "")
re)
(let ((mode (with-ivy-window (bound-and-true-p search-default-mode))))
(if (functionp mode)
(mapconcat
(lambda (x)
(if (string-match-p "\\`[^$\\^]+\\'" x)
(funcall mode x)
x))
(split-string re "\\b") "")
re))
t))

(defun swiper--re-builder (str)
Expand Down

0 comments on commit c66769d

Please sign in to comment.