diff options
author | Dan Davison <dandavison7@gmail.com> | 2019-07-26 23:23:31 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2019-07-28 21:49:57 -0400 |
commit | a0b7c42599eebbb4250962fd3819c55b320cb4c2 (patch) | |
tree | 99d78a8ebc2a23c8ddbecd72916cf4ccb71b056a /src/paint.rs | |
parent | 5b3a8fc79e867d175c894399f8d9f98765856f3c (diff) |
Infer homologous pairs of lines
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/src/paint.rs b/src/paint.rs index b5ec5d01..237f1153 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -146,38 +146,15 @@ impl<'a> Painter<'a> { Vec<Vec<(StyleModifier, &'b str)>>, Vec<Vec<(StyleModifier, &'b str)>>, ) { - if minus_lines.len() == plus_lines.len() { - edits::infer_edit_sections( - minus_lines, - plus_lines, - config.minus_style_modifier, - config.minus_emph_style_modifier, - config.plus_style_modifier, - config.plus_emph_style_modifier, - 0.66, - ) - } else { - Self::get_diff_style_sections_plain(minus_lines, plus_lines, config) - } - } - - fn get_diff_style_sections_plain<'m, 'p>( - minus_lines: &'m Vec<String>, - plus_lines: &'p Vec<String>, - config: &config::Config, - ) -> ( - Vec<Vec<(StyleModifier, &'m str)>>, - Vec<Vec<(StyleModifier, &'p str)>>, - ) { - let mut minus_line_sections = Vec::new(); - for line in minus_lines.iter() { - minus_line_sections.push(vec![(config.minus_style_modifier, &line[..])]); - } - let mut plus_line_sections = Vec::new(); - for line in plus_lines.iter() { - plus_line_sections.push(vec![(config.plus_style_modifier, &line[..])]); - } - (minus_line_sections, plus_line_sections) + edits::infer_edit_sections( + minus_lines, + plus_lines, + config.minus_style_modifier, + config.minus_emph_style_modifier, + config.plus_style_modifier, + config.plus_emph_style_modifier, + 0.66, + ) } } |