summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJD Smith <93749+jdtsmith@users.noreply.github.com>2024-10-31 21:30:46 -0400
committerDaniel Mendler <mail@daniel-mendler.de>2024-11-01 17:43:10 +0100
commitd20892abbc34dc4e92b9d93c157b47dd7cdfbc9e (patch)
treeea6137a4b7cdaec70c78a4f7a8716cf7228278bc
parent090299074e0153340c20207ef1ec5efeafeac51d (diff)
format-candidates: ensure suffix is right-aligned when possible
-rw-r--r--corfu.el17
1 files changed, 5 insertions, 12 deletions
diff --git a/corfu.el b/corfu.el
index ea01161..976a88e 100644
--- a/corfu.el
+++ b/corfu.el
@@ -739,23 +739,16 @@ FRAME is the existing frame."
(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))
- (setq width (min width max-width))
+ (setq width (min (max corfu-min-width width) max-width))
(list pw width
(cl-loop for (cand prefix suffix) in cands collect
(truncate-string-to-width
(concat
- prefix (make-string (max 0 (- pw (string-width prefix))) ?\s)
+ prefix (make-string (- pw (string-width prefix)) ?\s)
cand
- (when (/= sw 0)
- (make-string (+ (max 0 (- cw (string-width cand)))
- (max 0 (- sw (string-width suffix))))
- ?\s))
+ (make-string (max 1 (- width pw (string-width cand)
+ (string-width suffix)))
+ ?\s)
suffix)
width)))))