on master help sign in
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.

commit1de02a147c1738015aa26dea7c8fd313f3741d8e authorA-Walrus <ofek.r.guy@gmail.com> dateTue 11 Oct 2022, 11:37 (4 years ago) parent2c36e33
1 file changed+6−8
helix-term/src/ui/editor.rs+6−8
helix-term/src/ui/editor.rs+6−8
@@ -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