summaryrefslogtreecommitdiff
path: root/corfu.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-11-04 23:06:13 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2024-11-05 09:12:46 +0100
commita297daee27d23db87f47df6b11b14292bd35895f (patch)
tree5879f8e44939308958dac3ad258c4ba1f4a7a72b /corfu.el
parentd7c2fabbc6ae6a295895188e0a38524a69db09da (diff)
Restrict the fringe width to 16
Diffstat (limited to 'corfu.el')
-rw-r--r--corfu.el22
1 files changed, 11 insertions, 11 deletions
diff --git a/corfu.el b/corfu.el
index 3d82031..273df1e 100644
--- a/corfu.el
+++ b/corfu.el
@@ -1015,13 +1015,13 @@ A scroll bar is displayed from LO to LO+BAR."
(with-current-buffer (corfu--make-buffer " *corfu*")
(let* ((ch (default-line-height))
(cw (default-font-width))
- (ml (ceiling (* cw corfu-left-margin-width)))
- (bw (ceiling (* cw corfu-scroll-bar-width)))
- (mr (max bw (ceiling (* cw corfu-right-margin-width))))
+ ;; Even for larger fringes, fringe bitmaps can only have a width
+ ;; between 1 and 16. Therefore restrict the fringe width to 16.
+ (ml (min 16 (ceiling (* cw corfu-left-margin-width))))
+ (mr (min 16 (ceiling (* cw corfu-right-margin-width))))
+ (bw (min mr (ceiling (* cw corfu-scroll-bar-width))))
(marginl (and (> ml 0) (propertize " " 'display `(space :width (,ml)))))
- ;; PROBLEM: Even if the fringe is allowed to be larger, fringe
- ;; bitmaps can only have a width between 1 and 16. :(
- (fringe (and (<= 1 mr 16) (display-graphic-p)))
+ (fringe (display-graphic-p))
(sbar (if fringe
#(" " 0 1 (display (right-fringe corfu--bar corfu-scroll-bar)))
(concat (propertize " " 'display `(space :align-to (- right (,bw))))
@@ -1045,13 +1045,13 @@ A scroll bar is displayed from LO to LO+BAR."
(- yb pheight lh border border)
yb))
(row 0)
- (bbits (1- (ash 1 bw))))
+ (bmp (logxor (1- (ash 1 mr)) (1- (ash 1 bw)))))
(setq right-fringe-width (if fringe mr 0))
- (when (and (> right-fringe-width 0) (not (eq (get 'corfu--bar 'corfu--bar-bits) bbits)))
- (define-fringe-bitmap 'corfu--bar (vector (put 'corfu--bar 'corfu--bar-bits bbits))
- 1 mr '(top periodic))
+ (unless (or (= right-fringe-width 0) (eq (get 'corfu--bar 'corfu--bmp) bmp))
+ (put 'corfu--bar 'corfu--bmp bmp)
+ (define-fringe-bitmap 'corfu--bar (vector (lognot bmp)) 1 mr '(top periodic))
(define-fringe-bitmap 'corfu--nil [])
- ;; Fringe bitmaps require symbol face specification, define internal faces.
+ ;; Fringe bitmaps require symbol face specification, define internal face.
(set-face-attribute (make-face 'corfu--bar-cur) nil
:inherit '(corfu-scroll-bar corfu-current)))
(with-silent-modifications