squash! Add buffering to stdout when it's not a terminal

Co-authored-by: sourlemon207 <jw1756@protonmail.com>
This commit is contained in:
Thayne McCombs 2021-11-15 22:21:34 -07:00 committed by David Peter
parent 7b7876e701
commit e990a13405
2 changed files with 4 additions and 1 deletions

View file

@ -93,7 +93,8 @@ fn print_entry_colorized<W: Write>(
} }
if wants_to_quit.load(Ordering::Relaxed) { 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(); ExitCode::KilledBySigint.exit();
} }

View file

@ -280,6 +280,7 @@ fn spawn_receiver(
} }
} }
} }
num_results += 1; num_results += 1;
if let Some(max_results) = config.max_results { if let Some(max_results) = config.max_results {
if num_results >= 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 // 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: // anything to the console, yet. In this case, sort the results and print them:
buffer.sort(); buffer.sort();