Skip to content

Commit

Permalink
Write directly, not by appending to output buffer
Browse files Browse the repository at this point in the history
This was a bug when a box decoration was subsequently drawn since the
decoration enclosed pending content in the output buffer.
  • Loading branch information
dandavison committed Jun 3, 2023
1 parent d327bad commit 481d3c1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/handlers/grep.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::fmt::Write;

use lazy_static::lazy_static;
use regex::Regex;
Expand Down Expand Up @@ -136,7 +135,7 @@ impl<'a> StateMachine<'a> {
if new_path {
// Emit new path header line
if !first_path {
let _ = self.painter.output_buffer.write_char('\n');
writeln!(self.painter.writer)?;
}
handlers::hunk_header::write_line_of_code_with_optional_path_and_line_number(
"",
Expand All @@ -156,7 +155,7 @@ impl<'a> StateMachine<'a> {
)?
}
if new_section {
let _ = self.painter.output_buffer.write_str("--\n");
writeln!(self.painter.writer, "--")?;
}
// Emit the actual grep hit line
let code_style_sections = match (&grep_line.line_type, &grep_line.submatches) {
Expand Down

0 comments on commit 481d3c1

Please sign in to comment.