@@ -401,6 +401,23 @@ impl EditorView {
401 let text_style = theme.get("ui.text");
401 let text_style = theme.get("ui.text");
402 let whitespace_style = theme.get("ui.virtual.whitespace");
402 let whitespace_style = theme.get("ui.virtual.whitespace");
404+ let mut is_in_indent_area = true;
405+ let mut last_line_indent_level = 0;
406+ let indent_style = theme
407+ .try_get("ui.virtual.indent-guide")
408+ .unwrap_or_else(|| theme.get("comment"));
410+ let draw_indent_guides = |indent_level, line, surface: &mut Surface| {
411+ for i in 0..(indent_level / tab_width as u16) {
413+ viewport.x + (i * tab_width as u16) - offset.col as u16,
404 'outer: for event in highlights {
421 'outer: for event in highlights {
405 match event {
422 match event {
406 HighlightEvent::HighlightStart(span) => {
423 HighlightEvent::HighlightStart(span) => {
@@ -453,8 +470,18 @@ impl EditorView {
473+ // This is an empty line; draw indent guides at previous line's
474+ // indent level to avoid breaking the guides on blank lines.
476+ draw_indent_guides(last_line_indent_level, line, surface);
477+ } else if is_in_indent_area {
478+ // A line with whitespace only
479+ draw_indent_guides(visual_x, line, surface);
456 visual_x = 0;
482 visual_x = 0;
457 line += 1;
483 line += 1;
484+ is_in_indent_area = true;
459 // TODO: with proper iter this shouldn't be necessary
486 // TODO: with proper iter this shouldn't be necessary
460 if line >= viewport.height {
487 if line >= viewport.height {
@@ -499,6 +526,11 @@ impl EditorView {
529+ if is_in_indent_area && !(grapheme == " " || grapheme == "\t") {
530+ draw_indent_guides(visual_x, line, surface);
531+ is_in_indent_area = false;
532+ last_line_indent_level = visual_x;
503 visual_x = visual_x.saturating_add(width as u16);
535 visual_x = visual_x.saturating_add(width as u16);