summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThayne McCombs <astrothayne@gmail.com>2021-11-15 22:21:34 -0700
committerDavid Peter <sharkdp@users.noreply.github.com>2021-11-26 21:23:47 +0100
commite990a13405883581e174d484a9f55c7451023bd1 (patch)
treee793c548b7ee97642fadbaa9acdf1a970dc43bab
parent7b7876e7012665b558a9873d505b8d7e2e6c8e5e (diff)
squash! Add buffering to stdout when it's not a terminal
Co-authored-by: sourlemon207 <jw1756@protonmail.com>
-rw-r--r--src/output.rs3
-rw-r--r--src/walk.rs2
2 files changed, 4 insertions, 1 deletions
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<W: Write>(
}
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();