branch: externals/consult
commit dafd078534b7e5fe8307cebb585fa7ade6f585ea
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    consult-buffer: Fix buffer list reordering (Fix #354)
---
 consult.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/consult.el b/consult.el
index b967907ae9..b4ff1813da 100644
--- a/consult.el
+++ b/consult.el
@@ -4119,14 +4119,15 @@ Report progress and return a list of the results"
   "Buffer preview function."
   (let ((orig-buf (current-buffer)))
     (lambda (action cand)
-      (when (and (eq action 'preview)
-                 ;; Only preview in current window and other window.
-                 ;; Preview in frames and tabs is not possible since these 
don't get cleaned up.
-                 (or (eq consult--buffer-display #'switch-to-buffer)
-                     (eq consult--buffer-display 
#'switch-to-buffer-other-window)))
+      ;; Only preview in current window and other window.
+      ;; Preview in frames and tabs is not possible since these don't get 
cleaned up.
+      (when (or (eq consult--buffer-display #'switch-to-buffer)
+                (eq consult--buffer-display #'switch-to-buffer-other-window))
         (cond
-         ((and cand (get-buffer cand)) (consult--buffer-action cand 'norecord))
-         ((buffer-live-p orig-buf) (consult--buffer-action orig-buf 
'norecord)))))))
+         ((and cand (eq action 'preview) (get-buffer cand))
+          (consult--buffer-action cand 'norecord))
+         ((and (memq action '(preview exit)) (buffer-live-p orig-buf))
+          (consult--buffer-action orig-buf 'norecord)))))))
 
 (defun consult--buffer-action (buffer &optional norecord)
   "Switch to BUFFER via `consult--buffer-display' function.

Reply via email to