improv: show ellipsis if nothing else fits

If buffer is small enough that char+ellipsis doesn't fit, then show
ellipsis alone. If buffer is smaller than ellipsis, show nothing.
This commit is contained in:
Hojjat 2026-02-20 15:25:02 -07:00 committed by Jeremy Soller
parent d304a49536
commit a8873a0536
3 changed files with 31 additions and 0 deletions

View file

@ -1860,11 +1860,26 @@ impl ShapeLine {
current_visual_line.w = starting_line.w + ending_line.w + ellipsis_w;
current_visual_line.spaces = starting_line.spaces + ending_line.spaces;
}
None if forward_pass_overflowed && width > ellipsis_w => {
// buffer is small enough that the forward pass didn't fit
// only show the ellipsis
current_visual_line
.ranges
.push(self.ellipsis_vlrange(if self.rtl {
unicode_bidi::Level::rtl()
} else {
unicode_bidi::Level::ltr()
}));
current_visual_line.ellipsized = true;
current_visual_line.w = ellipsis_w;
current_visual_line.spaces = 0;
}
_ => {
// everything fit in the forward pass
current_visual_line.ranges = starting_line.ranges;
current_visual_line.w = starting_line.w;
current_visual_line.spaces = starting_line.spaces;
current_visual_line.ellipsized = false;
}
}
}