summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--corfu.el25
1 files changed, 11 insertions, 14 deletions
diff --git a/corfu.el b/corfu.el
index 3dcfeb3..ef403f7 100644
--- a/corfu.el
+++ b/corfu.el
@@ -436,19 +436,16 @@ Set to nil in order to disable confirmation."
"Return PROP from METADATA."
(cdr (assq prop metadata)))
-(defun corfu--format-candidate ()
- "Format candidates."
- (let ((mw (ceiling (* corfu-margin-width (frame-char-width)))))
- (lambda (c)
- (if (consp c)
- (concat
- (cadr c) (car c)
- (propertize " " 'display
- `(space :align-to (- right ,(length (caddr c)) (,mw))))
- (if (text-property-not-all 0 (length (caddr c)) 'face nil (caddr c))
- (caddr c)
- (propertize (caddr c) 'face 'completions-annotations)))
- c))))
+(defun corfu--format-candidate (cand)
+ "Format annotated CAND string."
+ (replace-regexp-in-string
+ "[ \t]*\n[ \t]*" " "
+ (if (consp cand)
+ (concat (cadr cand) (car cand)
+ (if (text-property-not-all 0 (length (caddr cand)) 'face nil (caddr cand))
+ (caddr cand)
+ (propertize (caddr cand) 'face 'completions-annotations)))
+ cand)))
(defun corfu--show-candidates (beg end str metadata)
"Update display given BEG, END, STR and METADATA."
@@ -459,7 +456,7 @@ Set to nil in order to disable confirmation."
(bar (ceiling (* corfu-count corfu-count) corfu--total))
(lo (min (- corfu-count bar 1) (floor (* corfu-count start) corfu--total)))
(cands (funcall corfu--highlight (seq-subseq corfu--candidates start last)))
- (ann-cands (mapcar (corfu--format-candidate) (corfu--annotate metadata cands))))
+ (ann-cands (mapcar #'corfu--format-candidate (corfu--annotate metadata cands))))
;; Nonlinearity at the end and the beginning
(when (/= start 0)
(setq lo (max 1 lo)))