summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-05-30 22:20:27 -0400
committerDan Davison <dandavison7@gmail.com>2020-05-30 22:22:42 -0400
commit8134487582327483609dba639d83b5caf6b4aa7a (patch)
tree8a04cc8f8fd1699e02e259612e3e1fc0910276cf /src/paint.rs
parenteec0fb23cfcf64cd2a5da78895112ce7fe3f1108 (diff)
Bug fix: non-emph styling was incorrect
The code was relying on inequality-by-value of e.g. --minus-style and --minus-emph-style. So when those were the same by value, the behavior was incorrect. See also previous commit eec0fb23cfcf64cd2a5da78895112ce7fe3f1108
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/paint.rs b/src/paint.rs
index 6a827e5d..b5ef0a49 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -241,34 +241,22 @@ impl<'a> Painter<'a> {
config.max_line_distance_for_naively_paired_lines,
);
if config.minus_non_emph_style != config.minus_emph_style {
- Self::set_non_emph_styles(
- &mut diff_sections.0,
- config.minus_emph_style,
- config.minus_non_emph_style,
- );
+ Self::set_non_emph_styles(&mut diff_sections.0, config.minus_non_emph_style);
}
if config.plus_non_emph_style != config.plus_emph_style {
- Self::set_non_emph_styles(
- &mut diff_sections.1,
- config.plus_emph_style,
- config.plus_non_emph_style,
- );
+ Self::set_non_emph_styles(&mut diff_sections.1, config.plus_non_emph_style);
}
diff_sections
}
- fn set_non_emph_styles(
- style_sections: &mut Vec<Vec<(Style, &str)>>,
- emph_style: Style,
- non_emph_style: Style,
- ) {
+ fn set_non_emph_styles(style_sections: &mut Vec<Vec<(Style, &str)>>, non_emph_style: Style) {
for line_sections in style_sections {
// If there multiple diff styles in the line, then the line must have some inferred
// edit operations and so the non-emph color style should be used for the non-emph
// style sections.
if style_sections_contain_more_than_one_style(line_sections) {
for section in line_sections.iter_mut() {
- if section.0 != emph_style {
+ if !section.0.is_emph {
*section = (non_emph_style, section.1);
}
}