From d7d873e11b3278cab64de95cebc76c628304e81e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 31 Dec 2019 00:02:20 -0500 Subject: [PATCH] Fix counsel-projectile-find-file from occur buffers #2268 counsel-projectile-find-file-action would open the candidate from wrong buffer. This is an experimental fix. --- modules/completion/ivy/config.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index e097c3975..e9ed06f73 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -200,6 +200,14 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." :config (set-popup-rule! "^\\*ivy-occur" :size 0.35 :ttl 0 :quit nil) + ;; HACK Fix an issue where `counsel-projectile-find-file-action' would try to + ;; open a candidate in an occur buffer relative to the wrong buffer, + ;; causing it to fail to find the file we want. + (defadvice! +ivy--run-from-ivy-directory-a (orig-fn &rest args) + :around #'counsel-projectile-find-file-action + (let ((default-directory (ivy-state-directory ivy-last))) + (apply orig-fn args))) + ;; Don't use ^ as initial input. Set this here because `counsel' defines more ;; of its own, on top of the defaults. (setq ivy-initial-inputs-alist nil)