diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8375cf4..2b76f33bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ `.ino` files are now treated as C++. +### Display + +Difftastic no longer uses purple to highlight regions that are missing +styling. This was intended as a debug feature, but it in practice it +only highlighted trailing whitespace for a few languages. + ## 0.45 (released 3rd March 2023) ### Diffing diff --git a/src/display/side_by_side.rs b/src/display/side_by_side.rs index 478ff337e..82dad365d 100644 --- a/src/display/side_by_side.rs +++ b/src/display/side_by_side.rs @@ -516,7 +516,6 @@ pub fn print( lhs_lines[lhs_line_num.as_usize()], source_dims.content_width, display_options.tab_width, - display_options.use_color, lhs_highlights.get(lhs_line_num).unwrap_or(&vec![]), Side::Left, ), @@ -527,7 +526,6 @@ pub fn print( rhs_lines[rhs_line_num.as_usize()], source_dims.content_width, display_options.tab_width, - display_options.use_color, rhs_highlights.get(rhs_line_num).unwrap_or(&vec![]), Side::Right, ), diff --git a/src/display/style.rs b/src/display/style.rs index bc4221609..4f676e79c 100644 --- a/src/display/style.rs +++ b/src/display/style.rs @@ -109,10 +109,6 @@ fn split_string_by_width(s: &str, max_width: usize, tab_width: usize) -> Vec<(&s res } -fn highlight_missing_style_bug(s: &str) -> String { - s.on_purple().to_string() -} - /// Return a copy of `src` with all the tab characters replaced by /// `tab_width` strings. pub fn replace_tabs(src: &str, tab_width: usize) -> String { @@ -127,7 +123,6 @@ pub fn split_and_apply( line: &str, max_len: usize, tab_width: usize, - use_color: bool, styles: &[(SingleLineSpan, Style)], side: Side, ) -> Vec { @@ -149,13 +144,7 @@ pub fn split_and_apply( let part = replace_tabs(part, tab_width); let mut res = String::with_capacity(part.len() + pad); - if use_color { - // If we're syntax highlighting and have no - // styles, that's a bug. - res.push_str(&highlight_missing_style_bug(&part)); - } else { - res.push_str(&part); - } + res.push_str(&part); if matches!(side, Side::Left) { res.push_str(&" ".repeat(pad)); @@ -236,10 +225,6 @@ pub fn split_and_apply( /// Return a copy of `line` with styles applied to all the spans /// specified. fn apply_line(line: &str, styles: &[(SingleLineSpan, Style)]) -> String { - if styles.is_empty() && !line.is_empty() { - return highlight_missing_style_bug(line); - } - let line_bytes = byte_len(line); let mut res = String::with_capacity(line.len()); let mut i = 0; @@ -556,19 +541,12 @@ mod tests { ); } - #[test] - fn test_split_and_apply_missing() { - let res = split_and_apply("foo", 3, TAB_WIDTH, true, &[], Side::Left); - assert_eq!(res, vec![highlight_missing_style_bug("foo")]) - } - #[test] fn test_split_and_apply() { let res = split_and_apply( "foo", 3, TAB_WIDTH, - true, &[( SingleLineSpan { line: 0.into(), @@ -588,7 +566,6 @@ mod tests { "foobar", 6, TAB_WIDTH, - true, &[( SingleLineSpan { line: 0.into(), @@ -608,7 +585,6 @@ mod tests { "foobar", 3, TAB_WIDTH, - true, &[ ( SingleLineSpan { @@ -638,7 +614,6 @@ mod tests { "foobar ", 6, TAB_WIDTH, - true, &[( SingleLineSpan { line: 0.into(),