@@ -24,7 +24,7 @@ use helix_view::{
24 keyboard::{KeyCode, KeyModifiers},
24 keyboard::{KeyCode, KeyModifiers},
25 Document, Editor, Theme, View,
25 Document, Editor, Theme, View,
27−use std::{borrow::Cow, path::PathBuf};
27+use std::{borrow::Cow, cmp::min, path::PathBuf};
29use tui::buffer::Buffer as Surface;
29use tui::buffer::Buffer as Surface;
@@ -468,12 +468,18 @@ impl EditorView {
468 let starting_indent =
468 let starting_indent =
469 (offset.col / tab_width) + config.indent_guides.skip_levels as usize;
469 (offset.col / tab_width) + config.indent_guides.skip_levels as usize;
471+ // Don't draw indent guides outside of view
472+ let end_indent = min(
474+ // Add tab_width - 1 to round up, since the first visible
475+ // indent might be a bit after offset.col
476+ offset.col + viewport.width as usize + (tab_width - 1),
471− for i in starting_indent..(indent_level / tab_width) {
479+ for i in starting_indent..end_indent {
472 let x = (viewport.x as usize + (i * tab_width) - offset.col) as u16;
480 let x = (viewport.x as usize + (i * tab_width) - offset.col) as u16;
473 let y = viewport.y + line;
481 let y = viewport.y + line;
474− if !surface.in_bounds(x, y) {
482+ debug_assert!(surface.in_bounds(x, y));
477 surface.set_string(x, y, &indent_guide_char, indent_guide_style);
483 surface.set_string(x, y, &indent_guide_char, indent_guide_style);