branch: master
commit 73d9f4a4f40c08aba4c442bf2093a306f016a367
Author: Campbell Barton <[email protected]>
Commit: Oleh Krehel <[email protected]>
Place cursor at the begging of matches (for grep)
The cursor was being placed after the matches, adding an extra step if
you need to operate on the word, after opening the file with a match.
Fixes #2209
---
counsel.el | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/counsel.el b/counsel.el
index 038bb8b..5c94bcb 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1372,6 +1372,8 @@ Typical value: '(recenter)."
(goto-char (point-min))
(forward-line (1- (string-to-number line-number)))
(re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
+ (when swiper-goto-start-of-match
+ (goto-char (match-beginning 0)))
(swiper--ensure-visible)
(run-hooks 'counsel-grep-post-action-hook)
(unless (eq ivy-exit 'done)
@@ -2985,6 +2987,8 @@ substituted by the search regexp and file, respectively.
Neither
(forward-line (1- line-number)))
(setq counsel-grep-last-line line-number)
(re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
+ (when swiper-goto-start-of-match
+ (goto-char (match-beginning 0)))
(run-hooks 'counsel-grep-post-action-hook)
(if (eq ivy-exit 'done)
(swiper--ensure-visible)