diff --git a/src/printer.rs b/src/printer.rs index 21845beb2..118488303 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -274,12 +274,7 @@ impl Printer { self.write_file_sep(); self.write_heading(path.as_ref()); } else if !self.heading && self.with_filename { - self.write_path(path.as_ref()); - if self.null { - self.write(b"\x00"); - } else { - self.write(b":"); - } + self.write_non_heading_path(path.as_ref()); } if let Some(line_number) = line_number { self.line_number(line_number, b':'); @@ -361,6 +356,22 @@ impl Printer { } } + fn write_non_heading_path>(&mut self, path: P) { + if self.wtr.supports_color() { + let _ = self.wtr.fg(self.color_choice.heading); + let _ = self.wtr.attr(Attr::Bold); + } + self.write_path(path.as_ref()); + if self.wtr.supports_color() { + let _ = self.wtr.reset(); + } + if self.null { + self.write(b"\x00"); + } else { + self.write(b":"); + } + } + fn line_number(&mut self, n: u64, sep: u8) { if self.wtr.supports_color() { let _ = self.wtr.fg(self.color_choice.line_number);