From fdd8bbf16bdbc19d2e814c463c1c327ee941eba9 Mon Sep 17 00:00:00 2001
From: A-Walrus <58790821+A-Walrus@users.noreply.github.com>
Date: Sat, 6 Aug 2022 18:46:23 +0300
Subject: [PATCH] Fix indent guide styling (#3324)

* Fix incorrect indent guide styling

Before the indent guides on top of whitespace inherited the theme
from them. Now they do not.

* Fix dark_plus theme indent_guides

* Use whitespace style as fallback for indent-guide

* Fix dark_plus theme indent_guides

* Move indent_guide style patching out of loop
---
 helix-term/src/ui/editor.rs   | 19 +++++++++----------
 runtime/themes/dark_plus.toml |  2 +-
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index d99f1a4e..94ad8aea 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -414,7 +414,13 @@ impl EditorView {
 
         let mut is_in_indent_area = true;
         let mut last_line_indent_level = 0;
-        let indent_style = theme.get("ui.virtual.indent-guide");
+
+        // use whitespace style as fallback for indent-guide
+        let indent_guide_style = text_style.patch(
+            theme
+                .try_get("ui.virtual.indent-guide")
+                .unwrap_or_else(|| theme.get("ui.virtual.whitespace")),
+        );
 
         let draw_indent_guides = |indent_level, line, surface: &mut Surface| {
             if !config.indent_guides.render {
@@ -430,7 +436,7 @@ impl EditorView {
                     viewport.x + (i * tab_width as u16) - offset.col as u16,
                     viewport.y + line,
                     &indent_guide_char,
-                    indent_style,
+                    indent_guide_style,
                 );
             }
         };
@@ -487,14 +493,7 @@ impl EditorView {
                                 );
                             }
 
-                            // This is an empty line; draw indent guides at previous line's
-                            // indent level to avoid breaking the guides on blank lines.
-                            if visual_x == 0 {
-                                draw_indent_guides(last_line_indent_level, line, surface);
-                            } else if is_in_indent_area {
-                                // A line with whitespace only
-                                draw_indent_guides(visual_x, line, surface);
-                            }
+                            draw_indent_guides(last_line_indent_level, line, surface);
 
                             visual_x = 0;
                             line += 1;
diff --git a/runtime/themes/dark_plus.toml b/runtime/themes/dark_plus.toml
index 1512a650..451c28b5 100644
--- a/runtime/themes/dark_plus.toml
+++ b/runtime/themes/dark_plus.toml
@@ -81,7 +81,7 @@
 
 "ui.virtual.whitespace" = { fg = "dark_gray" }
 "ui.virtual.ruler" = { bg = "borders" }
-"ui.virtual.indent-guide" = { bg = "dark_gray4" }
+"ui.virtual.indent-guide" = { fg = "dark_gray4" }
 
 "warning" = { fg = "gold2" }
 "error" = { fg = "red" }