fix(default): region handling in +default/search-buffer
+default/search-buffer now correctly uses the active selection when invoking `consult-line` (on 'SPC s s' or 'SPC s b'). Close #5406 Co-authored-by: Sævar Berg <saevarb@users.noreply.github.com>
This commit is contained in:
parent
a03d30047c
commit
6b5c34a1db
2 changed files with 11 additions and 5 deletions
|
@ -704,7 +704,7 @@
|
|||
;;; <leader> s --- search
|
||||
(:prefix-map ("s" . "search")
|
||||
:desc "Search buffer" "b"
|
||||
(cond ((featurep! :completion vertico) #'consult-line)
|
||||
(cond ((featurep! :completion vertico) #'+default/search-buffer)
|
||||
((featurep! :completion ivy) #'swiper)
|
||||
((featurep! :completion helm) #'swiper))
|
||||
:desc "Search all open buffers" "B"
|
||||
|
|
|
@ -26,12 +26,18 @@ If prefix ARG is set, prompt for a directory to search from."
|
|||
"Conduct a text search on the current buffer.
|
||||
If a selection is active, pre-fill the prompt with it."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(cond ((or (featurep! :completion helm) (featurep! :completion ivy))
|
||||
(call-interactively
|
||||
(if (region-active-p)
|
||||
#'swiper-isearch-thing-at-point
|
||||
#'swiper-isearch))
|
||||
((featurep! :completion vertico) #'consult-line))))
|
||||
#'swiper-isearch)))
|
||||
((featurep! :completion vertico)
|
||||
(if (region-active-p)
|
||||
(let ((start (region-beginning))
|
||||
(end (region-end)))
|
||||
(deactivate-mark)
|
||||
(consult-line (buffer-substring-no-properties start end)))
|
||||
(call-interactively #'consult-line)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +default/search-project (&optional arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue