diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-11-20 14:13:57 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-11-21 12:27:51 -0500 |
commit | b5c0223e781cc248d85450bed4408b3b9b36d70f (patch) | |
tree | 40c61c341115cbe2fe95c31303315b8d1680aecf /src/parse_styles.rs | |
parent | 7a64fa5a26314c05c811d7c1276388a4963fa0bd (diff) |
Set is_emph explicitly on *-emph-styles
This addresses a bug triggered by doing things like
minus-style = minus-emph-style
That was causing the is_emph bit to be set on minus-style, with
undesirable consequences.
Diffstat (limited to 'src/parse_styles.rs')
-rw-r--r-- | src/parse_styles.rs | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/src/parse_styles.rs b/src/parse_styles.rs index 538b333a..197b2694 100644 --- a/src/parse_styles.rs +++ b/src/parse_styles.rs @@ -24,13 +24,7 @@ pub fn parse_styles(opt: &cli::Opt) -> HashMap<String, Style> { make_line_number_styles(opt, &mut styles); styles.insert( "inline-hint-style", - style_from_str( - &opt.inline_hint_style, - None, - None, - opt.computed.true_color, - false, - ), + style_from_str(&opt.inline_hint_style, None, None, opt.computed.true_color), ); styles.insert( "git-minus-style", @@ -46,7 +40,10 @@ pub fn parse_styles(opt: &cli::Opt) -> HashMap<String, Style> { _ => *style::GIT_DEFAULT_PLUS_STYLE, }), ); - resolve_style_references(styles, opt) + let mut resolved_styles = resolve_style_references(styles, opt); + resolved_styles.get_mut("minus-emph-style").unwrap().is_emph = true; + resolved_styles.get_mut("plus-emph-style").unwrap().is_emph = true; + resolved_styles } fn resolve_style_references( @@ -112,7 +109,6 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - false, ); let minus_emph_style = style_from_str( @@ -126,11 +122,9 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - true, ); - let minus_non_emph_style = - style_from_str(&opt.minus_non_emph_style, None, None, true_color, false); + let minus_non_emph_style = style_from_str(&opt.minus_non_emph_style, None, None, true_color); // The style used to highlight a removed empty line when otherwise it would be invisible due to // lack of background color in minus-style. @@ -145,10 +139,9 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - false, ); - let zero_style = style_from_str(&opt.zero_style, None, None, true_color, false); + let zero_style = style_from_str(&opt.zero_style, None, None, true_color); let plus_style = style_from_str( &opt.plus_style, @@ -161,7 +154,6 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - false, ); let plus_emph_style = style_from_str( @@ -175,11 +167,9 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - true, ); - let plus_non_emph_style = - style_from_str(&opt.plus_non_emph_style, None, None, true_color, false); + let plus_non_emph_style = style_from_str(&opt.plus_non_emph_style, None, None, true_color); // The style used to highlight an added empty line when otherwise it would be invisible due to // lack of background color in plus-style. @@ -194,11 +184,10 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe )), None, true_color, - false, ); let whitespace_error_style = - style_from_str(&opt.whitespace_error_style, None, None, true_color, false); + style_from_str(&opt.whitespace_error_style, None, None, true_color); styles.extend([ ("minus-style", minus_style), @@ -220,19 +209,19 @@ fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleRe fn make_line_number_styles(opt: &cli::Opt, styles: &mut HashMap<&str, StyleReference>) { let true_color = opt.computed.true_color; let line_numbers_left_style = - style_from_str(&opt.line_numbers_left_style, None, None, true_color, false); + style_from_str(&opt.line_numbers_left_style, None, None, true_color); let line_numbers_minus_style = - style_from_str(&opt.line_numbers_minus_style, None, None, true_color, false); + style_from_str(&opt.line_numbers_minus_style, None, None, true_color); let line_numbers_zero_style = - style_from_str(&opt.line_numbers_zero_style, None, None, true_color, false); + style_from_str(&opt.line_numbers_zero_style, None, None, true_color); let line_numbers_plus_style = - style_from_str(&opt.line_numbers_plus_style, None, None, true_color, false); + style_from_str(&opt.line_numbers_plus_style, None, None, true_color); let line_numbers_right_style = - style_from_str(&opt.line_numbers_right_style, None, None, true_color, false); + style_from_str(&opt.line_numbers_right_style, None, None, true_color); styles.extend([ ("line-numbers-minus-style", line_numbers_minus_style), @@ -253,7 +242,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, styles: &mut HashMap<&str Some(&opt.commit_decoration_style), opt.deprecated_commit_color.as_deref(), true_color, - false, ) ), ("file-style", @@ -263,7 +251,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, styles: &mut HashMap<&str Some(&opt.file_decoration_style), opt.deprecated_file_color.as_deref(), true_color, - false, ) ), ("hunk-header-style", @@ -273,7 +260,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, styles: &mut HashMap<&str Some(&opt.hunk_header_decoration_style), opt.deprecated_hunk_color.as_deref(), true_color, - false, ) ), ("hunk-header-file-style", @@ -282,7 +268,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, styles: &mut HashMap<&str None, None, true_color, - false, ) ), ("hunk-header-line-number-style", @@ -291,7 +276,6 @@ fn make_commit_file_hunk_header_styles(opt: &cli::Opt, styles: &mut HashMap<&str None, None, true_color, - false, ) ), ]); @@ -302,7 +286,6 @@ fn style_from_str( default: Option<Style>, decoration_style_string: Option<&str>, true_color: bool, - is_emph: bool, ) -> StyleReference { if is_style_reference(style_string) { StyleReference::Reference(style_string.to_owned()) @@ -312,7 +295,6 @@ fn style_from_str( default, decoration_style_string, true_color, - is_emph, )) } } @@ -322,7 +304,6 @@ fn style_from_str_with_handling_of_special_decoration_attributes( default: Option<Style>, decoration_style_string: Option<&str>, true_color: bool, - is_emph: bool, ) -> StyleReference { if is_style_reference(style_string) { StyleReference::Reference(style_string.to_owned()) @@ -333,7 +314,6 @@ fn style_from_str_with_handling_of_special_decoration_attributes( default, decoration_style_string, true_color, - is_emph, ), ) } @@ -345,7 +325,6 @@ fn style_from_str_with_handling_of_special_decoration_attributes_and_respecting_ decoration_style_string: Option<&str>, deprecated_foreground_color_arg: Option<&str>, true_color: bool, - is_emph: bool, ) -> StyleReference { if is_style_reference(style_string) { StyleReference::Reference(style_string.to_owned()) @@ -356,7 +335,6 @@ fn style_from_str_with_handling_of_special_decoration_attributes_and_respecting_ decoration_style_string, deprecated_foreground_color_arg, true_color, - is_emph )) } } |