mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 17:36:19 +04:00
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.
This commit is contained in:
parent
94346356e7
commit
7483c76222
@ -360,14 +360,14 @@ pub fn set_string_truncated(
|
|||||||
let mut start_index = self.index_of(x, y);
|
let mut start_index = self.index_of(x, y);
|
||||||
let mut index = self.index_of(max_offset as u16, y);
|
let mut index = self.index_of(max_offset as u16, y);
|
||||||
|
|
||||||
let total_width = string.width();
|
let content_width = string.width();
|
||||||
let truncated = total_width > width;
|
let truncated = content_width > width;
|
||||||
if ellipsis && truncated {
|
if ellipsis && truncated {
|
||||||
self.content[start_index].set_symbol("…");
|
self.content[start_index].set_symbol("…");
|
||||||
start_index += 1;
|
start_index += 1;
|
||||||
}
|
}
|
||||||
if !truncated {
|
if !truncated {
|
||||||
index -= width - total_width;
|
index -= width - content_width;
|
||||||
}
|
}
|
||||||
for (byte_offset, s) in graphemes.rev() {
|
for (byte_offset, s) in graphemes.rev() {
|
||||||
let width = s.width();
|
let width = s.width();
|
||||||
@ -384,6 +384,7 @@ pub fn set_string_truncated(
|
|||||||
self.content[i].reset();
|
self.content[i].reset();
|
||||||
}
|
}
|
||||||
index -= width;
|
index -= width;
|
||||||
|
x_offset += width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(x_offset as u16, y)
|
(x_offset as u16, y)
|
||||||
|
Loading…
Reference in New Issue
Block a user