1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-07-06 06:27:36 +02:00
This commit is contained in:
Cabbache
2024-10-24 13:56:55 +02:00
parent 4b0e5a11b9
commit c0558a808c

View File

@ -804,8 +804,7 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for SummarySink<'p, 's, M, W> {
.stats .stats
.as_ref() .as_ref()
.expect("Histogram should enable stats tracking"); .expect("Histogram should enable stats tracking");
let total: u64 = stats.histogram().values().sum(); if self.match_count > 0 {
if total > 0 {
let bin_iter = 0..=(stats.bytes_searched() / bin_size); let bin_iter = 0..=(stats.bytes_searched() / bin_size);
let terminal_str = bin_iter let terminal_str = bin_iter
.map(|i| { .map(|i| {
@ -818,8 +817,10 @@ impl<'p, 's, M: Matcher, W: WriteColor> Sink for SummarySink<'p, 's, M, W> {
}) })
.collect::<Vec<Vec<u8>>>() .collect::<Vec<Vec<u8>>>()
.join(searcher.line_terminator().as_bytes()); .join(searcher.line_terminator().as_bytes());
self.write_path_field()?; if self.path.is_some() {
self.write_line_term(searcher)?; self.write_path_field()?;
self.write_line_term(searcher)?;
}
self.write(&terminal_str)?; self.write(&terminal_str)?;
self.write_line_term(searcher)?; self.write_line_term(searcher)?;
} }