on master help sign in
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

commitfdd8bbf16bdbc19d2e814c463c1c327ee941eba9 authorA-Walrus <58790821+A-Walrus@users.noreply.github.com> dateSat 6 Aug 2022, 18:46 (4 years ago) parent4dd3577
2 files changed+10−11
helix-term/src/ui/editor.rs+9−10 runtime/themes/dark_plus.toml+1−1
helix-term/src/ui/editor.rs+9−10
@@ -414,7 +414,13 @@ impl EditorView {
414414
415415 let mut is_in_indent_area = true;
416416 let mut last_line_indent_level = 0;
417− let indent_style = theme.get("ui.virtual.indent-guide");
417+
418+ // use whitespace style as fallback for indent-guide
419+ let indent_guide_style = text_style.patch(
420+ theme
421+ .try_get("ui.virtual.indent-guide")
422+ .unwrap_or_else(|| theme.get("ui.virtual.whitespace")),
423+ );
418424
419425 let draw_indent_guides = |indent_level, line, surface: &mut Surface| {
420426 if !config.indent_guides.render {
@@ -430,7 +436,7 @@ impl EditorView {
430436 viewport.x + (i * tab_width as u16) - offset.col as u16,
431437 viewport.y + line,
432438 &indent_guide_char,
433− indent_style,
439+ indent_guide_style,
434440 );
435441 }
436442 };
@@ -487,14 +493,7 @@ impl EditorView {
487493 );
488494 }
489495
490− // This is an empty line; draw indent guides at previous line's
491− // indent level to avoid breaking the guides on blank lines.
492− if visual_x == 0 {
493− draw_indent_guides(last_line_indent_level, line, surface);
494− } else if is_in_indent_area {
495− // A line with whitespace only
496− draw_indent_guides(visual_x, line, surface);
497− }
496+ draw_indent_guides(last_line_indent_level, line, surface);
498497
499498 visual_x = 0;
500499 line += 1;
runtime/themes/dark_plus.toml+1−1
@@ -81,7 +81,7 @@
8181
8282"ui.virtual.whitespace" = { fg = "dark_gray" }
8383"ui.virtual.ruler" = { bg = "borders" }
84−"ui.virtual.indent-guide" = { bg = "dark_gray4" }
84+"ui.virtual.indent-guide" = { fg = "dark_gray4" }
8585
8686"warning" = { fg = "gold2" }
8787"error" = { fg = "red" }