tui buffer: Handle multi-width graphemes in set_string_anchored

We should skip zero-width graphemes and reset only long (more than
1-width) graphemes.

Connects #12036
This commit is contained in:
Michael Davis 2025-01-23 18:12:15 -05:00
parent 9d6ea773e9
commit 0b9701e899
No known key found for this signature in database

View file

@ -349,15 +349,20 @@ impl Buffer {
if start_index > end_index {
break;
}
let width = s.width();
if width == 0 {
continue;
}
self.content[start_index].set_symbol(s);
self.content[start_index].set_style(style(byte_offset));
for i in start_index + 1..end_index {
// Reset following cells if multi-width (they would be hidden by the grapheme):
for i in start_index + 1..start_index + width {
self.content[i].reset();
}
start_index += s.width();
start_index += width;
}
(x, y)