Skip to content

Commit 0f66d93

Browse files
committed
Avoid printing 1 lines skipped
1 parent db72336 commit 0f66d93

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ui_test/src/diff.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ use diff::{chars, lines, Result, Result::*};
44
#[derive(Default)]
55
struct DiffState<'a> {
66
skipped_lines: usize,
7+
/// When we skip a line, remember it, in case
8+
/// we end up only skipping one line. In that case we just
9+
/// print the line instead of `... skipped one line ...`
10+
last_skipped_line: Option<&'a str>,
711
/// When we see a removed line, we don't print it, we
812
/// keep it around to compare it with the next added line.
913
prev_left: Option<&'a str>,
1014
}
1115

1216
impl<'a> DiffState<'a> {
1317
fn print_skip(&mut self) {
14-
if self.skipped_lines != 0 {
15-
eprintln!("... {} lines skipped", self.skipped_lines);
18+
match self.skipped_lines {
19+
0 => {}
20+
1 => eprintln!(" {}", self.last_skipped_line.unwrap()),
21+
_ => eprintln!("... {} lines skipped", self.skipped_lines),
1622
}
1723
self.skipped_lines = 0;
1824
}
@@ -38,8 +44,9 @@ impl<'a> DiffState<'a> {
3844
self.print_prev();
3945
self.prev_left = Some(l);
4046
}
41-
Both(..) => {
47+
Both(l, _) => {
4248
self.print_prev();
49+
self.last_skipped_line = Some(l);
4350
self.skipped_lines += 1
4451
}
4552
Right(r) => {

0 commit comments

Comments
 (0)