diff options
author | Dan Davison <dandavison7@gmail.com> | 2022-03-07 08:14:39 -0500 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2022-03-07 12:58:28 -0500 |
commit | a7765f8003b572430cf1255709b8732240a703f0 (patch) | |
tree | e5092a04b1c48ec4e15e54eea146bdb40a24d772 | |
parent | c0bb90c86e90fcafbb6aacab996960ec55a0f5cd (diff) |
Flush minus/plus line buffers in additional code locations
Fixes #1002
-rw-r--r-- | src/handlers/diff_header.rs | 2 | ||||
-rw-r--r-- | src/paint.rs | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs index 4b82bec4..d00bab10 100644 --- a/src/handlers/diff_header.rs +++ b/src/handlers/diff_header.rs @@ -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), @@ -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), diff --git a/src/paint.rs b/src/paint.rs index 709d7d6c..7f497fe1 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -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, |