Skip to content

Commit

Permalink
Flush minus/plus line buffers in additional code locations
Browse files Browse the repository at this point in the history
Fixes #1002
  • Loading branch information
dandavison committed Mar 7, 2022
1 parent c0bb90c commit a7765f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/handlers/diff_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl<'a> StateMachine<'a> {
));
}

self.painter.paint_buffered_minus_and_plus_lines();
// In color_only mode, raw_line's structure shouldn't be changed.
// So it needs to avoid fn _handle_diff_header_header_line
// (it connects the plus_file and minus_file),
Expand Down Expand Up @@ -127,6 +128,7 @@ impl<'a> StateMachine<'a> {
));
self.current_file_pair = Some((self.minus_file.clone(), self.plus_file.clone()));

self.painter.paint_buffered_minus_and_plus_lines();
// In color_only mode, raw_line's structure shouldn't be changed.
// So it needs to avoid fn _handle_diff_header_header_line
// (it connects the plus_file and minus_file),
Expand Down
3 changes: 3 additions & 0 deletions src/paint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ impl<'p> Painter<'p> {
}

pub fn paint_buffered_minus_and_plus_lines(&mut self) {
if self.minus_lines.is_empty() && self.plus_lines.is_empty() {
return;
}
paint_minus_and_plus_lines(
MinusPlus::new(&self.minus_lines, &self.plus_lines),
&mut self.line_numbers_data,
Expand Down

0 comments on commit a7765f8

Please # to comment.