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
This commit is contained in:
parent
fdd8bbf16b
commit
c00b8f7ad7
1 changed files with 19 additions and 0 deletions
|
@ -529,6 +529,8 @@ impl EditorView {
|
||||||
(grapheme.as_ref(), width)
|
(grapheme.as_ref(), width)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let cut_off_start = offset.col.saturating_sub(visual_x as usize);
|
||||||
|
|
||||||
if !out_of_bounds {
|
if !out_of_bounds {
|
||||||
// if we're offscreen just keep going until we hit a new line
|
// if we're offscreen just keep going until we hit a new line
|
||||||
surface.set_string(
|
surface.set_string(
|
||||||
|
@ -541,7 +543,24 @@ impl EditorView {
|
||||||
style
|
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") {
|
if is_in_indent_area && !(grapheme == " " || grapheme == "\t") {
|
||||||
draw_indent_guides(visual_x, line, surface);
|
draw_indent_guides(visual_x, line, surface);
|
||||||
is_in_indent_area = false;
|
is_in_indent_area = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue