branch: externals/swiper commit c66769d25b90693ce6eedc3d4dbbf8dbce7b8dcf Author: Basil L. Contovounesios <conto...@tcd.ie> Commit: Basil L. Contovounesios <conto...@tcd.ie>
Fix search-default-mode lookup in swiper-isearch * swiper.el (swiper--normalize-regex): Look up search-default-mode where swiper-isearch was called from, not in the minibuffer. Fixes #3026. --- swiper.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/swiper.el b/swiper.el index c9bec1e3e7..674890b47a 100644 --- a/swiper.el +++ b/swiper.el @@ -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)