Skip to content

Commit

Permalink
fix: Calculate suffix in pixel width
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Nov 4, 2024
1 parent 6a9e8f5 commit 222e7c6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,13 @@ calculate to the right side."
((= pos-first pos-end)
(cons column-start win-width)))))
(t
(let ((column-end (+ column-start win-width)))
(let* ((column-end (+ column-start win-width))
(remain-spaces (- column-end pos-end)))
(cond ((or sideline-force-display-if-exceeds
(<= str-len (- column-end pos-end))
(<= str-len remain-spaces)
(and sideline-truncate
(< (* win-width sideline-truncate-min-available-space-ratio)
(- column-end pos-end))))
remain-spaces)))
(cons column-end pos-end))))))))

(defun sideline--find-line (str-len on-left &optional direction exceeded)
Expand Down Expand Up @@ -605,11 +606,11 @@ FACE, NAME, ON-LEFT, and ORDER for details."

(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))
(used-space (- pos-start occ-pt))
(available-space (1+ (- win-width used-space)))
(suffix nil))
(when (and sideline-truncate-suffix
(> available-space (length sideline-truncate-suffix)))
(> available-space (sideline--str-len sideline-truncate-suffix)))
(setq suffix (copy-sequence sideline-truncate-suffix))
(set-text-properties 0 (length suffix)
(text-properties-at (1- (length str)) str)
Expand Down

0 comments on commit 222e7c6

Please sign in to comment.