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

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

[elpa] externals/marginalia 2b85b73 130/241: fix marginalia--full-candid


From: Stefan Monnier
Subject: [elpa] externals/marginalia 2b85b73 130/241: fix marginalia--full-candidate
Date: Fri, 28 May 2021 20:49:12 -0400 (EDT)

branch: externals/marginalia
commit 2b85b73bca6e1610b86b0de8c2c4c414a9e99185
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    fix marginalia--full-candidate
    
    cc @oantolin
    
    It is a bit ugly that we are now switching back and forth,
    but running the annotators in the context of the original
    window makes more sense for most annotators. It seems to be
    less error-prone this way.
---
 marginalia.el | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 714ffca..56627e4 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -554,18 +554,19 @@ component of a full file path.
 
 This function returns what would be the minibuffer contents after
 using `minibuffer-force-complete' on the candidate CAND."
-  (if (minibufferp)
-      (let* ((contents (minibuffer-contents))
-             (pt (- (point) (minibuffer-prompt-end)))
-             (bounds (completion-boundaries
-                      (substring contents 0 pt)
-                      minibuffer-completion-table
-                      minibuffer-completion-predicate
-                      (substring contents pt))))
-        (concat (substring contents 0 (car bounds))
-                cand
-                (substring contents (+ pt (cdr bounds)))))
-    ;; not in a minibuffer, trust that cand already conveys all
+  (if-let (win (active-minibuffer-window))
+      (with-selected-window win
+        (let* ((contents (minibuffer-contents))
+               (pt (- (point) (minibuffer-prompt-end)))
+               (bounds (completion-boundaries
+                        (substring contents 0 pt)
+                        minibuffer-completion-table
+                        minibuffer-completion-predicate
+                        (substring contents pt))))
+          (concat (substring contents 0 (car bounds))
+                  cand
+                  (substring contents (+ pt (cdr bounds))))))
+    ;; no minibuffer is active, trust that cand already conveys all
     ;; necessary information (there's not much else we can do)
     cand))
 



reply via email to

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