Function difft::display::context::match_preceding_blanks
source · fn match_preceding_blanks(
line_nums: &[(Option<LineNumber>, Option<LineNumber>)],
lhs_lines: &[&str],
rhs_lines: &[&str]
) -> Vec<(Option<LineNumber>, Option<LineNumber>)>
Expand description
For every line number pair, if there are blank lines preceding the pair, add those blank lines to the vec.
This substantially improves alignment, leading to more readable diffs.
We don’t need to match blank lines following each pair. After
matching up all the matching lines, we just display the remaining
lines side-by-side regardless of content (see
ensure_contiguous
). If there are blank lines immediately
following the pair, they will get aligned by this.