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

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

[elpa] externals/corfu 58459b6143: Ensure that annotations don't fall of


From: ELPA Syncer
Subject: [elpa] externals/corfu 58459b6143: Ensure that annotations don't fall off the popup (Fix #135)
Date: Fri, 25 Feb 2022 10:57:22 -0500 (EST)

branch: externals/corfu
commit 58459b614372a39e2cf80f4ffd959a5d2272fa8a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Ensure that annotations don't fall off the popup (Fix #135)
---
 corfu.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/corfu.el b/corfu.el
index 0b6e5acc40..e92bce61c9 100644
--- a/corfu.el
+++ b/corfu.el
@@ -717,22 +717,27 @@ there hasn't been any input, then quit."
   (let* ((cw (cl-loop for x in cands maximize (string-width (car x))))
          (pw (cl-loop for x in cands maximize (string-width (cadr x))))
          (sw (cl-loop for x in cands maximize (string-width (caddr x))))
-         (width (+ pw cw sw)))
+         (width (+ pw cw sw))
+         ;; -4 because of margins and some additional safety
+         (max-width (min corfu-max-width (- (frame-width) 4))))
+    (when (> width max-width)
+      (setq sw (max 0 (- max-width pw cw))
+            width (+ pw cw sw)))
     (when (< width corfu-min-width)
       (setq cw (+ cw (- corfu-min-width width))
             width corfu-min-width))
-    ;; -4 because of margins and some additional safety
-    (setq width (min width corfu-max-width (- (frame-width) 4)))
+    (setq width (min width max-width))
     (list pw width
           (cl-loop for (cand prefix suffix) in cands collect
                    (truncate-string-to-width
                     (concat prefix
-                            (make-string (- pw (string-width prefix)) ?\s)
+                            (make-string (max 0 (- pw (string-width prefix))) 
?\s)
                             cand
                             (when (/= sw 0)
-                              (make-string (+ (- cw (string-width cand))
-                                              (- sw (string-width suffix)))
-                                           ?\s))
+                              (make-string
+                               (+ (max 0 (- cw (string-width cand)))
+                                  (max 0 (- sw (string-width suffix))))
+                               ?\s))
                             suffix)
                     width)))))
 



reply via email to

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