emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 011626a 343/399: ivy.el (ivy-occur-press): Improve when wi


From: Oleh Krehel
Subject: [elpa] master 011626a 343/399: ivy.el (ivy-occur-press): Improve when window config changed
Date: Sat, 20 Jul 2019 14:57:53 -0400 (EDT)

branch: master
commit 011626ae77dbd9dba47c4aa0cae325d6c7273e7d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-occur-press): Improve when window config changed
    
    Scenario:
    
    1. In a window, `swiper-isearch' for something and `ivy-occur'.
    2. Now there are 2 windows. Select some other buffer in the original window.
    3. Switch to *ivy-occur* and press "f".
    
    - before: ivy's confused and goes to some line number in the wrong buffer
    - after: ivy restores the attached buffer to the window where it was
---
 ivy.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ivy.el b/ivy.el
index 5a33cb0..cec9da2 100644
--- a/ivy.el
+++ b/ivy.el
@@ -4642,12 +4642,16 @@ EVENT gives the mouse position."
     ((swiper swiper-isearch counsel-git-grep counsel-grep counsel-ag 
counsel-rg)
      (let ((window (ivy-state-window ivy-occur-last))
            (buffer (ivy-state-buffer ivy-occur-last)))
-       (when (and (or (not (window-live-p window))
-                      (equal window (selected-window)))
-                  (buffer-live-p buffer))
-         (save-selected-window
-           (setf (ivy-state-window ivy-occur-last)
-                 (display-buffer buffer))))))
+       (if (not (buffer-live-p buffer))
+           (error "Buffer was killed")
+         (cond ((or (not (window-live-p window))
+                    (equal window (selected-window)))
+                (save-selected-window
+                  (setf (ivy-state-window ivy-occur-last)
+                        (display-buffer buffer))))
+               ((not (equal (window-buffer window) buffer))
+                (with-selected-window window
+                  (switch-to-buffer buffer)))))))
 
     ((counsel-describe-function counsel-describe-variable)
      (setf (ivy-state-window ivy-occur-last)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]