diff options
author | Wilfred Hughes <me@wilfred.me.uk> | 2021-11-19 00:31:55 -0800 |
---|---|---|
committer | Wilfred Hughes <me@wilfred.me.uk> | 2021-11-19 00:31:55 -0800 |
commit | 440ca8d0de0e277b8476c350d85be459ba9039dd (patch) | |
tree | af6e17017e8b07c18b3ac454da87b32e3d6b2be1 | |
parent | 70f384652ac84548ee2c151dff8b0c1283ab9060 (diff) |
Style single-line display consistently with other displays0.12.0
-rw-r--r-- | src/side_by_side.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/side_by_side.rs b/src/side_by_side.rs index 8eb9c5ea1..458aaed05 100644 --- a/src/side_by_side.rs +++ b/src/side_by_side.rs @@ -66,8 +66,7 @@ fn display_single_column(display_path: &str, lang_name: &str, src: &str, color: .color(color) .to_string(), ); - // TODO: factor out the common styling from style::apply_colors. - result.push_str(&line.color(color).bold().to_string()); + result.push_str(line); result.push('\n'); } @@ -175,11 +174,19 @@ pub fn display_hunks( lhs_mps: &[MatchedPos], rhs_mps: &[MatchedPos], ) -> String { + let lhs_colored_src = apply_colors(lhs_src, true, lhs_mps); + let rhs_colored_src = apply_colors(rhs_src, false, rhs_mps); + if lhs_src == "" { - return display_single_column(display_path, lang_name, rhs_src, Color::BrightGreen); + return display_single_column( + display_path, + lang_name, + &rhs_colored_src, + Color::BrightGreen, + ); } if rhs_src == "" { - return display_single_column(display_path, lang_name, lhs_src, Color::BrightRed); + return display_single_column(display_path, lang_name, &lhs_colored_src, Color::BrightRed); } let mut lhs_styles: HashMap<LineNumber, Vec<(SingleLineSpan, Style)>> = HashMap::new(); @@ -194,9 +201,6 @@ pub fn display_hunks( styles.push((span, style)); } - let lhs_colored_src = apply_colors(lhs_src, true, lhs_mps); - let rhs_colored_src = apply_colors(rhs_src, false, rhs_mps); - let lhs_lines = split_lines_nonempty(lhs_src); let rhs_lines = split_lines_nonempty(rhs_src); let lhs_colored_lines = split_lines_nonempty(&lhs_colored_src); |