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
|
;;;###autoload
|
||||||
(defun +ivy-git-grep-other-window-action (x)
|
(defun +ivy-git-grep-other-window-action (x)
|
||||||
"Opens the current candidate in another window."
|
"Opens the current candidate in another window."
|
||||||
(let (dest-window)
|
(when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" x)
|
||||||
(cl-letf (((symbol-function 'find-file)
|
(select-window
|
||||||
(lambda (filename)
|
(with-ivy-window
|
||||||
(find-file-other-window filename)
|
(let ((file-name (match-string-no-properties 1 x))
|
||||||
(setq dest-window (selected-window)))))
|
(line-number (match-string-no-properties 2 x)))
|
||||||
(counsel-git-grep-action x)
|
(find-file-other-window (expand-file-name file-name counsel--git-grep-dir))
|
||||||
(select-window dest-window))))
|
(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