on master help sign in
update `x_offset` calculation in Buffer::set_string_truncated (#3839)
7483c76kristopherbullinger
helix-tui/src/buffer.rs+4−3
@@ -360,14 +360,14 @@ impl Buffer {
360 let mut start_index = self.index_of(x, y);
360 let mut start_index = self.index_of(x, y);
361 let mut index = self.index_of(max_offset as u16, y);
361 let mut index = self.index_of(max_offset as u16, y);
362
362
363− let total_width = string.width();
363+ let content_width = string.width();
364− let truncated = total_width > width;
364+ let truncated = content_width > width;
365 if ellipsis && truncated {
365 if ellipsis && truncated {
366 self.content[start_index].set_symbol("…");
366 self.content[start_index].set_symbol("…");
367 start_index += 1;
367 start_index += 1;
368 }
368 }
369 if !truncated {
369 if !truncated {
370− index -= width - total_width;
370+ index -= width - content_width;
371 }
371 }
372 for (byte_offset, s) in graphemes.rev() {
372 for (byte_offset, s) in graphemes.rev() {
373 let width = s.width();
373 let width = s.width();
@@ -384,6 +384,7 @@ impl Buffer {
384 self.content[i].reset();
384 self.content[i].reset();
385 }
385 }
386 index -= width;
386 index -= width;
387+ x_offset += width;
387 }
388 }
388 }
389 }
389 (x_offset as u16, y)
390 (x_offset as u16, y)