Skip to content

Commit

Permalink
Fix indent guide styling (helix-editor#3324)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
A-Walrus authored and thomasskk committed Sep 9, 2022
1 parent 0b31dc5 commit 01ac052
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,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 {
Expand All @@ -432,7 +438,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,
);
}
};
Expand Down Expand Up @@ -489,14 +495,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;
Expand Down
2 changes: 1 addition & 1 deletion runtime/themes/dark_plus.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 01ac052

Please sign in to comment.