Skip to content

Commit

Permalink
Fix tab highlight when tab is partially visible (helix-editor#3313)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
A-Walrus authored and thomasskk committed Sep 9, 2022
1 parent 01ac052 commit f711a17
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ impl EditorView {
(grapheme.as_ref(), width)
};

let cut_off_start = offset.col.saturating_sub(visual_x as usize);

if !out_of_bounds {
// if we're offscreen just keep going until we hit a new line
surface.set_string(
Expand All @@ -543,7 +545,24 @@ impl EditorView {
style
},
);
} else if cut_off_start != 0 && cut_off_start < width {
// partially on screen
let rect = Rect::new(
viewport.x as u16,
viewport.y + line,
(width - cut_off_start) as u16,
1,
);
surface.set_style(
rect,
if is_whitespace {
style.patch(whitespace_style)
} else {
style
},
);
}

if is_in_indent_area && !(grapheme == " " || grapheme == "\t") {
draw_indent_guides(visual_x, line, surface);
is_in_indent_area = false;
Expand Down

0 comments on commit f711a17

Please sign in to comment.