From 481d3c1a26096c30e19b29f7c22be0574bb6d4cf Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 3 Jun 2023 07:48:11 -0400 Subject: 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. --- src/handlers/grep.rs | 5 ++--- 1 file 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) { -- cgit v1.2.3