summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2023-06-03 07:48:11 -0400
committerDan Davison <dandavison7@gmail.com>2023-06-03 08:05:11 -0400
commit481d3c1a26096c30e19b29f7c22be0574bb6d4cf (patch)
tree39fefe10876279bf1b93d3bf5b6d4445376689e2
parentd327bad4d52813c289b58650ce4d2bbf2074c0c4 (diff)
Write directly, not by appending to output buffer
This was a bug when a box decoration was subsequently drawn since the decoration enclosed pending content in the output buffer.
-rw-r--r--src/handlers/grep.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/handlers/grep.rs b/src/handlers/grep.rs
index f8614f7d..772baf11 100644
--- a/src/handlers/grep.rs
+++ b/src/handlers/grep.rs
@@ -1,5 +1,4 @@
use std::borrow::Cow;
-use std::fmt::Write;
use lazy_static::lazy_static;
use regex::Regex;
@@ -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(
"",
@@ -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) {