diff options
author | Andrew Gallant <jamslam@gmail.com> | 2023-11-21 07:40:56 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2023-11-21 18:39:32 -0500 |
commit | c81caa673b743bdac04db75c32957200bf549695 (patch) | |
tree | 5b24c32fadc03a3788e5c455679b858b86e0d944 | |
parent | 082245dadb3854238e62b91aa95a46018cf16ef1 (diff) |
core: fix file separator bug
I introduced a regression in the migration off of the clap by having
both the buffer writer and the printer be responsible for printing file
separators in multi-threaded search. The buffer writer owns that
responsibility in multi-threaded search.
-rw-r--r-- | crates/core/flags/hiargs.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/core/flags/hiargs.rs b/crates/core/flags/hiargs.rs index 4f3b3f39..b4e0c096 100644 --- a/crates/core/flags/hiargs.rs +++ b/crates/core/flags/hiargs.rs @@ -592,7 +592,8 @@ impl HiArgs { &self, wtr: W, ) -> grep::printer::Standard<W> { - grep::printer::StandardBuilder::new() + let mut builder = grep::printer::StandardBuilder::new(); + builder .byte_offset(self.byte_offset) .color_specs(self.colors.clone()) .column(self.column) @@ -615,10 +616,17 @@ impl HiArgs { self.field_match_separator.clone().into_bytes(), ) .separator_path(self.path_separator.clone()) - .separator_search(self.file_separator.clone()) .stats(self.stats.is_some()) - .trim_ascii(self.trim) - .build(wtr) + .trim_ascii(self.trim); + // When doing multi-threaded searching, the buffer writer is + // responsible for writing separators since it is the only thing that + // knows whether something has been printed or not. But for the single + // threaded case, we don't use a buffer writer and thus can let the + // printer own this. + if self.threads == 1 { + builder.separator_search(self.file_separator.clone()); + } + builder.build(wtr) } /// Builds a "summary" printer where search results are aggregated on a |