Skip to content

Commit

Permalink
Only draw indent guides within bounds
Browse files Browse the repository at this point in the history
Better performance, and otherwise very long lines with lots of tabs
will wrap around the u16 and come back on the other side, messing up
the beginning skip_levels.
  • Loading branch information
A-Walrus authored and archseer committed Oct 17, 2022
1 parent 2c36e33 commit 1de02a1
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,14 @@ impl EditorView {

let starting_indent =
(offset.col / tab_width) + config.indent_guides.skip_levels as usize;
// TODO: limit to a max indent level too. It doesn't cause visual artifacts but it would avoid some
// extra loops if the code is deeply nested.

for i in starting_indent..(indent_level / tab_width) {
surface.set_string(
(viewport.x as usize + (i * tab_width) - offset.col) as u16,
viewport.y + line,
&indent_guide_char,
indent_guide_style,
);
let x = (viewport.x as usize + (i * tab_width) - offset.col) as u16;
let y = viewport.y + line;
if !surface.in_bounds(x, y) {
break;
}
surface.set_string(x, y, &indent_guide_char, indent_guide_style);
}
};

Expand Down

0 comments on commit 1de02a1

Please sign in to comment.