From 5e82ffca0217fe75445a73b990ade034427cd17a Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 20 Nov 2021 11:20:08 -0500 Subject: [PATCH] Always use non-emph style for right fill --- src/paint.rs | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/paint.rs b/src/paint.rs index b83a76da2..3e37f168c 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -444,46 +444,36 @@ impl<'p> Painter<'p> { ) -> (Option, Style) { // style: for right fill if line contains no emph sections // non_emph_style: for right fill if line contains emph sections - let (style, non_emph_style) = match state { - State::HunkMinus(None) | State::HunkMinusWrapped => { - (config.minus_style, config.minus_non_emph_style) - } + let non_emph_style = match state { + State::HunkMinus(None) | State::HunkMinusWrapped => config.minus_non_emph_style, State::HunkMinus(Some(raw_line)) => { // TODO: This is the second time we are parsing the ANSI sequences if let Some(ansi_term_style) = ansi::parse_first_style(raw_line) { - let style = Style { + Style { ansi_term_style, ..Style::new() - }; - (style, style) + } } else { - (config.minus_style, config.minus_non_emph_style) + config.minus_non_emph_style } } - State::HunkZero | State::HunkZeroWrapped => (config.zero_style, config.zero_style), - State::HunkPlus(None) | State::HunkPlusWrapped => { - (config.plus_style, config.plus_non_emph_style) - } + State::HunkZero | State::HunkZeroWrapped => config.zero_style, + State::HunkPlus(None) | State::HunkPlusWrapped => config.plus_non_emph_style, State::HunkPlus(Some(raw_line)) => { // TODO: This is the second time we are parsing the ANSI sequences if let Some(ansi_term_style) = ansi::parse_first_style(raw_line) { - let style = Style { + Style { ansi_term_style, ..Style::new() - }; - (style, style) + } } else { - (config.plus_style, config.plus_non_emph_style) + config.plus_non_emph_style } } - State::Blame(_, _) => (diff_sections[0].0, diff_sections[0].0), - _ => (config.null_style, config.null_style), - }; - let fill_style = if style_sections_contain_more_than_one_style(diff_sections) { - non_emph_style // line contains an emph section - } else { - style + State::Blame(_, _) => diff_sections[0].0, + _ => config.null_style, }; + let fill_style = non_emph_style; match ( fill_style.get_background_color().is_some(),