Skip to content

Commit

Permalink
fix: Use render data cache for suffix length
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Nov 4, 2024
1 parent 222e7c6 commit 476804d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,14 @@ FACE, NAME, ON-LEFT, and ORDER for details."
`cursor t))
title)))

;; Truncate
(when sideline-truncate
(let* ((win-width (sideline--render-data :win-width))
(used-space (- pos-start occ-pt))
(available-space (1+ (- win-width used-space)))
(suffix nil))
(when (and sideline-truncate-suffix
(> available-space (sideline--str-len sideline-truncate-suffix)))
(> available-space (sideline--render-data :suffix-width)))
(setq suffix (copy-sequence sideline-truncate-suffix))
(set-text-properties 0 (length suffix)
(text-properties-at (1- (length str)) str)
Expand Down Expand Up @@ -711,10 +712,12 @@ If argument ON-LEFT is non-nil, it will align to the left instead of right."
(sideline--with-buffer-window (or buffer (current-buffer))
(unless (funcall sideline-inhibit-display-function)
(setq sideline--render-data
`( :eol ,(sideline--window-end)
:bol ,(window-start)
:hscroll ,(sideline--window-hscroll)
:win-width ,(sideline--window-width)))
`( :eol ,(sideline--window-end)
:bol ,(window-start)
:hscroll ,(sideline--window-hscroll)
:win-width ,(sideline--window-width)
:suffix-width ,(and sideline-truncate-suffix
(sideline--str-len sideline-truncate-suffix))))
(run-hooks 'sideline-pre-render-hook)
(sideline--render-backends sideline-backends-left t)
(sideline--render-backends sideline-backends-right nil)
Expand Down

0 comments on commit 476804d

Please sign in to comment.