branch: externals/embark
commit 70f720f914b78bd11f84b0790df5f125945dd50f
Author: Omar Antolín <omar.anto...@gmail.com>
Commit: Omar Antolín <omar.anto...@gmail.com>

    Fix crazy bug: revert of an xref export buffer erased another buffer
    
    Thanks to @slayer152 for reporting this over on minad/consult#557.
---
 embark-consult.el | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index 171081314c..46386f3667 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -226,21 +226,25 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
       (set-buffer
        (xref--show-xref-buffer
         (lambda ()
-          (catch 'xref-items
-            (minibuffer-with-setup-hook
-                (lambda ()
-                  (insert input)
-                  (add-hook 'minibuffer-exit-hook
-                            (lambda ()
-                              (throw 'xref-items
-                                (xref-items
-                                 (or
-                                  (plist-get
-                                   (embark--maybe-transform-candidates)
-                                   :candidates)
-                                  (user-error "No candidates for export")))))
-                            nil t))
-              (consult-xref fetcher))))
+          (let ((candidates (funcall fetcher)))
+            (if (null (cdr candidates))
+                candidates
+              (catch 'xref-items
+                (minibuffer-with-setup-hook
+                    (lambda ()
+                      (insert input)
+                      (add-hook
+                       'minibuffer-exit-hook
+                       (lambda ()
+                         (throw 'xref-items
+                           (xref-items
+                            (or
+                             (plist-get
+                              (embark--maybe-transform-candidates)
+                              :candidates)
+                             (user-error "No candidates for export")))))
+                       nil t))
+                  (consult-xref fetcher))))))
         `((fetched-xrefs . ,(xref-items items))
           (window . ,(embark--target-window))
           (auto-jump . ,xref-auto-jump-to-first-xref)

Reply via email to