Skip to content

Commit

Permalink
fix: ensure proper truncation
Browse files Browse the repository at this point in the history
This commit ensures that labels are truncated correctly when they
exceed the available space, even if the space is very limited.

The truncation now avoids cutting off the label at zero width,
which could happen previously, by using a minimum width of 1
  • Loading branch information
KarimAziev committed Feb 4, 2024
1 parent a595583 commit f83141d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions igist.el
Original file line number Diff line number Diff line change
Expand Up @@ -1826,13 +1826,14 @@ Its default value is nil."
(when (plist-get props :children)
(setq children (plist-get props :children))
(setq children-indent (plist-get props :align-to-column))))
(when (and label (string-match-p "[\n\r\f]" label))
(setq label (string-join (split-string label "[\n\r\f]" t) " "))
(setq lablen (string-width label)))
(when (and (>= lablen 3)
not-last-col
(> lablen available-space))
(setq label
(truncate-string-to-width label available-space nil t t)))
(when (and label (string-match-p "[\n\r\f]" label))
(setq label (string-join (split-string label "[\n\r\f]" t) " ")))
(truncate-string-to-width label (max 1 available-space) nil nil t t)))
(push
(cond ((not sortable)
(propertize label 'igist-tabulated-list-column-name
Expand Down Expand Up @@ -1946,7 +1947,7 @@ column is the last one or not."
(when (and not-last-col
(>= label-width width))
(setq label (truncate-string-to-width
label width nil nil t "|")
label (max 1 width) nil nil t t)
label-width width))
(setq label (bidi-string-mark-left-to-right label))
(when-let ((shift
Expand Down

0 comments on commit f83141d

Please sign in to comment.