diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-06-17 17:00:10 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-06-17 17:00:10 -0400 |
commit | e8ba95d34b2738d2e76e9d1944b787b41c91fef6 (patch) | |
tree | 8a727194ba4c46e0d0609c3d685c987d9ce28c5b /src/paint.rs | |
parent | ba8cd95f5e0d2beeb4e6b2d040fea897d0e797ac (diff) |
Fix failing test: removal of whitespace error is not an error
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/paint.rs b/src/paint.rs index aaf9ad92..f946853c 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -324,11 +324,7 @@ impl<'a> Painter<'a> { } else { None }; - Self::update_styles( - &mut diff_sections.0, - config.whitespace_error_style, - minus_non_emph_style, - ); + Self::update_styles(&mut diff_sections.0, None, minus_non_emph_style); let plus_non_emph_style = if config.plus_non_emph_style != config.plus_emph_style { Some(config.plus_non_emph_style) } else { @@ -336,7 +332,7 @@ impl<'a> Painter<'a> { }; Self::update_styles( &mut diff_sections.1, - config.whitespace_error_style, + Some(config.whitespace_error_style), plus_non_emph_style, ); diff_sections @@ -352,7 +348,7 @@ impl<'a> Painter<'a> { /// should be applied to the added material. fn update_styles( style_sections: &mut Vec<Vec<(Style, &str)>>, - whitespace_error_style: Style, + whitespace_error_style: Option<Style>, non_emph_style: Option<Style>, ) { for line_sections in style_sections { @@ -360,7 +356,8 @@ impl<'a> Painter<'a> { style_sections_contain_more_than_one_style(line_sections); let should_update_non_emph_styles = non_emph_style.is_some() && line_has_emph_and_non_emph_sections; - let is_whitespace_error = is_whitespace_error(line_sections); + let is_whitespace_error = + whitespace_error_style.is_some() && is_whitespace_error(line_sections); for section in line_sections.iter_mut() { // If the line as a whole constitutes a whitespace error then highlight this // section if either (a) it is an emph section, or (b) the line lacks any @@ -368,7 +365,7 @@ impl<'a> Painter<'a> { if is_whitespace_error && (section.0.is_emph || !line_has_emph_and_non_emph_sections) { - *section = (whitespace_error_style, section.1); + *section = (whitespace_error_style.unwrap(), section.1); } // Otherwise, update the style if this is a non-emph section that needs updating. else if should_update_non_emph_styles && !section.0.is_emph { |