Line up additions and removals if they affect more than one line

html_output
Wilfred Hughes 2022-01-31 22:23:58 +07:00
parent 92c3836672
commit d1aa1d4925
2 changed files with 23 additions and 6 deletions

@ -5,6 +5,10 @@
Fixed an issue with changes being ignored in OCaml's `{||}` string
literals.
### Display
Fixed an issue where larger additions were not lined up with removals.
## 0.18.1 (released 30 January 2022)
Fixed a compilation issue on Rust 1.54 (0.18 only built on newer

@ -595,9 +595,7 @@ pub fn compact_gaps(
unpaired_lines.remove(0);
}
_ => {
// We can't compact this item, so start new chunk.
res.extend(unpaired_lines);
unpaired_lines = vec![(Some(*lhs_line), None)];
unpaired_lines.push((Some(*lhs_line), None));
}
}
}
@ -609,9 +607,7 @@ pub fn compact_gaps(
unpaired_lines.remove(0);
}
_ => {
// We can't compact this item, so start new chunk of one-side lines.
res.extend(unpaired_lines);
unpaired_lines = vec![(None, Some(*rhs_line))];
unpaired_lines.push((None, Some(*rhs_line)));
}
}
}
@ -805,4 +801,21 @@ mod tests {
]
)
}
#[test]
fn test_compact_gaps_with_larger_gap() {
let res = compact_gaps(&[
(Some(0.into()), None),
(Some(1.into()), None),
(None, Some(0.into())),
(None, Some(1.into())),
]);
assert_eq!(
res,
vec![
(Some(0.into()), Some(0.into())),
(Some(1.into()), Some(1.into())),
]
)
}
}