aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorA-Walrus2022-10-11 08:37:57 +0000
committerBlaž Hrastnik2022-10-17 15:38:16 +0000
commit1de02a147c1738015aa26dea7c8fd313f3741d8e (patch)
tree6e74b1f09ed9e1c99db2bd12cbff7295a970a9b5 /helix-term/src
parent2c36e33e0ac55d01baacb9714d9d77d7dd532d98 (diff)
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.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/ui/editor.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index e05136d0..4074534b 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -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);
}
};