on master help sign in
Fix tab highlight when tab is partially visible (#3313)

* Fix tab highlight when tab is partially visible * Make it style based, and not truncation based Dealing with truncating is a mess, especially when it comes to wide unicode graphemes. This way it should work no matter what. * Inline style calculation into branches

commitc00b8f7ad70e69d5365dc4d1247a8d47b53a8d2e authorA-Walrus <58790821+A-Walrus@users.noreply.github.com> dateSat 6 Aug 2022, 18:46 (4 years ago) parentfdd8bbf
1 file changed+19
helix-term/src/ui/editor.rs+19
helix-term/src/ui/editor.rs+19
@@ -529,6 +529,8 @@ impl EditorView {
529529 (grapheme.as_ref(), width)
530530 };
531531
532+ let cut_off_start = offset.col.saturating_sub(visual_x as usize);
533+
532534 if !out_of_bounds {
533535 // if we're offscreen just keep going until we hit a new line
534536 surface.set_string(
@@ -541,7 +543,24 @@ impl EditorView {
541543 style
542544 },
543545 );
546+ } else if cut_off_start != 0 && cut_off_start < width {
547+ // partially on screen
548+ let rect = Rect::new(
549+ viewport.x as u16,
550+ viewport.y + line,
551+ (width - cut_off_start) as u16,
552+ 1,
553+ );
554+ surface.set_style(
555+ rect,
556+ if is_whitespace {
557+ style.patch(whitespace_style)
558+ } else {
559+ style
560+ },
561+ );
544562 }
563+
545564 if is_in_indent_area && !(grapheme == " " || grapheme == "\t") {
546565 draw_indent_guides(visual_x, line, surface);
547566 is_in_indent_area = false;