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

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

[elpa] externals/corfu e6bfd22 26/29: Add corfu-min-width


From: Stefan Monnier
Subject: [elpa] externals/corfu e6bfd22 26/29: Add corfu-min-width
Date: Fri, 16 Apr 2021 18:44:18 -0400 (EDT)

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

    Add corfu-min-width
    
    Suggestion by @astoff
---
 corfu.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/corfu.el b/corfu.el
index 0507149..afc0862 100644
--- a/corfu.el
+++ b/corfu.el
@@ -47,6 +47,10 @@
   "Maximal number of candidates to show."
   :type 'integer)
 
+(defcustom corfu-min-width 15
+  "Minimum popup width."
+  :type 'integer)
+
 (defcustom corfu-cycle nil
   "Enable cycling for `corfu-next' and `corfu-previous'."
   :type 'boolean)
@@ -177,18 +181,17 @@
          (rborder (corfu--border (car size) (cdr size) 'corfu-border -1))
          (rbar (corfu--border (car size) (cdr size) 'corfu-bar (- (ceiling 
(car size) 3))))
          (col (+ (- pos (line-beginning-position)) corfu--base))
-         (width (- (window-total-width) col 10))
+         (max-width (min (/ (window-total-width) 2) (- (window-total-width) 
col)))
          (pixelpos (cdr (window-absolute-pixel-position pos)))
-         (row 0)
          (count (length lines))
-         (tail))
-    (if (< width 10)
-        (setq width (/ (window-total-width) 2)
+         (row 0) (tail) (width))
+    (if (< max-width corfu-min-width)
+        (setq width (max corfu-min-width (/ (window-total-width) 2))
               lines (mapcar (lambda (x) (truncate-string-to-width x width)) 
lines)
               width (apply #'max (mapcar #'string-width lines))
               col (max 0 (- col width 2)))
-      (setq lines (mapcar (lambda (x) (truncate-string-to-width x width)) 
lines)
-            width (apply #'max (mapcar #'string-width lines))))
+      (setq lines (mapcar (lambda (x) (truncate-string-to-width x max-width)) 
lines)
+            width (apply #'max corfu-min-width (mapcar #'string-width lines))))
     (save-excursion
       (when (and (>= count (floor (- (window-pixel-height) pixelpos) (cdr 
size)))
                  (< count (floor pixelpos (cdr size))))



reply via email to

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