diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-11-04 11:59:52 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-11-05 09:12:46 +0100 |
| commit | 08c3aeb46ccb2f00a716c563cf370464b1365c09 (patch) | |
| tree | 72c890868abc7e60b748e021d3a1e12214c9d1bc | |
| parent | 44424e7d04a5d58283bf8794d452a14e86341cb9 (diff) | |
Avoid truncation if scrollbar is shown in the fringe
| -rw-r--r-- | corfu.el | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -744,16 +744,14 @@ FRAME is the existing frame." (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 (- pw (string-width prefix)) ?\s) - cand - (when (> sw 0) - (make-string (max 0 (- width pw (string-width cand) - (string-width suffix))) - ?\s)) - suffix) - width))))) + (concat + prefix (make-string (- pw (string-width prefix)) ?\s) + cand + (when (> sw 0) + (make-string (max 0 (- width pw (string-width cand) + (string-width suffix))) + ?\s)) + suffix))))) (defun corfu--compute-scroll () "Compute new scroll position." @@ -1028,17 +1026,17 @@ A scroll bar is displayed from LO to LO+BAR." (propertize " " 'face 'corfu-bar 'display `(space :width (,bw)))))) (cbar (and fringe #(" " 0 1 (display (right-fringe corfu--bar corfu-current))))) (pos (posn-x-y pos)) - (width (+ (* width cw) ml mr (if fringe (- bw) 0))) + (pwidth (+ (* width cw) ml mr (if fringe (- bw) 0))) ;; XXX HACK: Minimum popup height must be at least 1 line of the ;; parent frame (gh:minad/corfu#261). - (height (max lh (* (length lines) ch))) + (pheight (max lh (* (length lines) ch))) (edge (window-inside-pixel-edges)) (border (alist-get 'internal-border-width corfu--frame-parameters)) (x (max 0 (min (+ (car edge) (- (or (car pos) 0) ml (* cw off) border)) - (- (frame-pixel-width) width)))) + (- (frame-pixel-width) pwidth)))) (yb (+ (cadr edge) (window-tab-line-height) (or (cdr pos) 0) lh)) (y (if (> (+ yb (* corfu-count ch) lh lh) (frame-pixel-height)) - (- yb height lh border border) + (- yb pheight lh border border) yb)) (row 0)) (setq right-fringe-width (if fringe bw 0)) @@ -1049,7 +1047,8 @@ A scroll bar is displayed from LO to LO+BAR." (apply #'insert (cl-loop for line in lines collect (let ((str (concat - marginl line + marginl + (if fringe line (truncate-string-to-width line width)) (or (and lo (<= lo row (+ lo bar)) sbar) (and (eq row curr) cbar)) "\n"))) @@ -1059,7 +1058,7 @@ A scroll bar is displayed from LO to LO+BAR." (cl-incf row) str))) (goto-char (point-min))) - (setq corfu--frame (corfu--make-frame corfu--frame x y width height)))))) + (setq corfu--frame (corfu--make-frame corfu--frame x y pwidth pheight)))))) (cl-defgeneric corfu--popup-hide () "Hide Corfu popup." |
