Skip to content

Commit 9b9cf88

Browse files
update x_offset calculation in Buffer::set_string_truncated
when `truncate_start` is `true`, the `x_offset` is now properly updated according to the width of the content or the truncated length.
1 parent ec81ec1 commit 9b9cf88

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

helix-tui/src/buffer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ impl Buffer {
343343
let mut start_index = self.index_of(x, y);
344344
let mut index = self.index_of(max_offset as u16, y);
345345

346-
let total_width = string.width();
347-
let truncated = total_width > width;
346+
let content_width = string.width();
347+
let truncated = content_width > width;
348348
if ellipsis && truncated {
349349
self.content[start_index].set_symbol("…");
350350
start_index += 1;
351351
}
352352
if !truncated {
353-
index -= width - total_width;
353+
index -= width - content_width;
354354
}
355355
for (byte_offset, s) in graphemes.rev() {
356356
let width = s.width();
@@ -367,6 +367,7 @@ impl Buffer {
367367
self.content[i].reset();
368368
}
369369
index -= width;
370+
x_offset += width;
370371
}
371372
}
372373
(x_offset as u16, y)

0 commit comments

Comments
 (0)