From e990a13405883581e174d484a9f55c7451023bd1 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Mon, 15 Nov 2021 22:21:34 -0700 Subject: [PATCH] squash! Add buffering to stdout when it's not a terminal Co-authored-by: sourlemon207 --- src/output.rs | 3 ++- src/walk.rs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/output.rs b/src/output.rs index 772e29a..f51d41f 100644 --- a/src/output.rs +++ b/src/output.rs @@ -93,7 +93,8 @@ fn print_entry_colorized( } if wants_to_quit.load(Ordering::Relaxed) { - stdout.flush()?; + // Ignore any errors on flush, because we're about to exit anyway + let _ = stdout.flush(); ExitCode::KilledBySigint.exit(); } diff --git a/src/walk.rs b/src/walk.rs index 61e38e4..f0cee6d 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -280,6 +280,7 @@ fn spawn_receiver( } } } + num_results += 1; if let Some(max_results) = config.max_results { if num_results >= max_results { @@ -294,6 +295,7 @@ fn spawn_receiver( } } } + // If we have finished fast enough (faster than max_buffer_time), we haven't streamed // anything to the console, yet. In this case, sort the results and print them: buffer.sort();