From 16312e3b157f9119111a6c65843c0e5a040f1b9b Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Sun, 2 Oct 2022 21:23:27 +0000 Subject: [PATCH] Create new style variable that patches on rainbow enabled --- helix-term/src/ui/editor.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 6e083885..1431bef2 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -425,13 +425,13 @@ impl EditorView { let mut last_line_indent_level = 0; // use whitespace style as fallback for indent-guide - let mut indent_guide_style = text_style.patch( + let indent_guide_style = text_style.patch( theme .try_get("ui.virtual.indent-guide") .unwrap_or_else(|| theme.get("ui.virtual.whitespace")), ); - let mut draw_indent_guides = |indent_level, line, surface: &mut Surface| { + let draw_indent_guides = |indent_level, line, surface: &mut Surface| { if !config.indent_guides.render { return; } @@ -441,17 +441,18 @@ impl EditorView { // extra loops if the code is deeply nested. for i in starting_indent..(indent_level / tab_width as u16) { - if config.indent_guides.rainbow { - let color_index: usize = i as usize % theme.rainbow_length(); - indent_guide_style = - indent_guide_style.patch(theme.get(&format!("rainbow.{}", color_index))); - } + let style = if config.indent_guides.rainbow { + let color_index = i as usize % theme.rainbow_length(); + indent_guide_style.patch(theme.get(&format!("rainbow.{}", color_index))) + } else { + indent_guide_style + }; surface.set_string( viewport.x + (i * tab_width as u16) - offset.col as u16, viewport.y + line, &indent_guide_char, - indent_guide_style, + style, ); } };