diff options
author | kristopherbullinger | 2022-11-17 01:06:50 +0000 |
---|---|---|
committer | GitHub | 2022-11-17 01:06:50 +0000 |
commit | 7483c762229516298c4a2d9398b9418dbc57198b (patch) | |
tree | 81d5eae5cad6228efaa1365817daa080e18ed317 /helix-tui/src | |
parent | 94346356e7657011adf0012651ec031b98d87411 (diff) |
update `x_offset` calculation in Buffer::set_string_truncated (#3839)
when `truncate_start` is `true`, the `x_offset` is now properly updated
according to the width of the content or the truncated length.
Diffstat (limited to 'helix-tui/src')
-rw-r--r-- | helix-tui/src/buffer.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-tui/src/buffer.rs b/helix-tui/src/buffer.rs index 5169196a..9b93c405 100644 --- a/helix-tui/src/buffer.rs +++ b/helix-tui/src/buffer.rs @@ -360,14 +360,14 @@ impl Buffer { let mut start_index = self.index_of(x, y); let mut index = self.index_of(max_offset as u16, y); - let total_width = string.width(); - let truncated = total_width > width; + let content_width = string.width(); + let truncated = content_width > width; if ellipsis && truncated { self.content[start_index].set_symbol("…"); start_index += 1; } if !truncated { - index -= width - total_width; + index -= width - content_width; } for (byte_offset, s) in graphemes.rev() { let width = s.width(); @@ -384,6 +384,7 @@ impl Buffer { self.content[i].reset(); } index -= width; + x_offset += width; } } (x_offset as u16, y) |