Skip to content

Commit 1de02a1

Browse files
A-Walrusarchseer
authored andcommitted
Only draw indent guides within bounds
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.
1 parent 2c36e33 commit 1de02a1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

helix-term/src/ui/editor.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,14 @@ impl EditorView {
467467

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

473471
for i in starting_indent..(indent_level / tab_width) {
474-
surface.set_string(
475-
(viewport.x as usize + (i * tab_width) - offset.col) as u16,
476-
viewport.y + line,
477-
&indent_guide_char,
478-
indent_guide_style,
479-
);
472+
let x = (viewport.x as usize + (i * tab_width) - offset.col) as u16;
473+
let y = viewport.y + line;
474+
if !surface.in_bounds(x, y) {
475+
break;
476+
}
477+
surface.set_string(x, y, &indent_guide_char, indent_guide_style);
480478
}
481479
};
482480

0 commit comments

Comments
 (0)