Skip to content

Commit a6c98ac

Browse files
kristopherbullingerFrederik Vestre
authored andcommitted
update x_offset calculation in Buffer::set_string_truncated (helix-editor#3839)
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 c2a06e1 commit a6c98ac

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
@@ -360,14 +360,14 @@ impl Buffer {
360360
let mut start_index = self.index_of(x, y);
361361
let mut index = self.index_of(max_offset as u16, y);
362362

363-
let total_width = string.width();
364-
let truncated = total_width > width;
363+
let content_width = string.width();
364+
let truncated = content_width > width;
365365
if ellipsis && truncated {
366366
self.content[start_index].set_symbol("…");
367367
start_index += 1;
368368
}
369369
if !truncated {
370-
index -= width - total_width;
370+
index -= width - content_width;
371371
}
372372
for (byte_offset, s) in graphemes.rev() {
373373
let width = s.width();
@@ -384,6 +384,7 @@ impl Buffer {
384384
self.content[i].reset();
385385
}
386386
index -= width;
387+
x_offset += width;
387388
}
388389
}
389390
(x_offset as u16, y)

0 commit comments

Comments
 (0)