Unnamed repository; edit this file 'description' to name the repository.
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
Michael Davis 2025-01-24
parent 9d6ea77 · commit 0b9701e
-rw-r--r--helix-tui/src/buffer.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs
index 405a0acd..bfcf35ac 100644
--- a/helix-tui/src/buffer.rs
+++ b/helix-tui/src/buffer.rs
@@ -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)