completion/ivy: fix M-RET opening result in other-window
This commit is contained in:
parent
806f856cb6
commit
28ba0607a5
1 changed files with 11 additions and 7 deletions
|
@ -216,10 +216,14 @@ counsel-rg)."
|
|||
;;;###autoload
|
||||
(defun +ivy-git-grep-other-window-action (x)
|
||||
"Opens the current candidate in another window."
|
||||
(let (dest-window)
|
||||
(cl-letf (((symbol-function 'find-file)
|
||||
(lambda (filename)
|
||||
(find-file-other-window filename)
|
||||
(setq dest-window (selected-window)))))
|
||||
(counsel-git-grep-action x)
|
||||
(select-window dest-window))))
|
||||
(when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" x)
|
||||
(select-window
|
||||
(with-ivy-window
|
||||
(let ((file-name (match-string-no-properties 1 x))
|
||||
(line-number (match-string-no-properties 2 x)))
|
||||
(find-file-other-window (expand-file-name file-name counsel--git-grep-dir))
|
||||
(goto-char (point-min))
|
||||
(forward-line (1- (string-to-number line-number)))
|
||||
(re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
|
||||
(run-hooks 'counsel-grep-post-action-hook)
|
||||
(selected-window))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue