Skip to content

fix(term): Measure truncation prefixes as whole strings - #905

Merged
JeanMertz merged 3 commits into
mainfrom
background-fill-mode-fixes
Jul 30, 2026
Merged

fix(term): Measure truncation prefixes as whole strings#905
JeanMertz merged 3 commits into
mainfrom
background-fill-mode-fixes

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

truncate_to_width summed per-cluster display widths to find where to
cut a string before appending an ellipsis. That sum is wrong for
sequences that ligate or combine into something narrower than their
parts: Arabic Lam-Alef spans two clusters that sum to two columns but
render as one, and similar sequences elsewhere could overspend the
budget and cut earlier than necessary. The fix measures each candidate
prefix as a whole string instead of summing its clusters, so ligating
sequences are accounted for at their true rendered width.

This also fixes a zero-width edge case: a zero-column input (e.g. a
lone ZWJ) now survives a zero-column budget unchanged, since it
already fits, rather than being dropped for the ellipsis. Only input
wider than the budget is truncated.

@JeanMertz
JeanMertz force-pushed the background-fill-mode-fixes branch from bafc6e5 to 06a13fe Compare July 30, 2026 10:45
`truncate_to_width` summed per-cluster display widths to find where to
cut a string before appending an ellipsis. That sum is wrong for
sequences that ligate or combine into something narrower than their
parts: Arabic Lam-Alef spans two clusters that sum to two columns but
render as one, and similar sequences elsewhere could overspend the
budget and cut earlier than necessary. The fix measures each candidate
prefix as a whole string instead of summing its clusters, so ligating
sequences are accounted for at their true rendered width.

This also fixes a zero-width edge case: a zero-column input (e.g. a
lone ZWJ) now survives a zero-column budget unchanged, since it
already fits, rather than being dropped for the ellipsis. Only input
wider than the budget is truncated.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz
JeanMertz force-pushed the background-fill-mode-fixes branch from 59be602 to 50a9061 Compare July 30, 2026 11:51
@JeanMertz
JeanMertz merged commit 9e7d1fb into main Jul 30, 2026
16 checks passed
@JeanMertz
JeanMertz deleted the background-fill-mode-fixes branch July 30, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant