Skip to content

Commit

Permalink
squash! Add buffering to stdout when it's not a terminal
Browse files Browse the repository at this point in the history
Co-authored-by: sourlemon207 <jw1756@protonmail.com>
  • Loading branch information
tmccombs and lemonlime339 committed Nov 16, 2021
1 parent 978e1c7 commit 7fb4ae9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 2 additions & 0 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ fn spawn_receiver(
}
}
}

num_results += 1;
if let Some(max_results) = config.max_results {
if num_results >= max_results {
Expand All @@ -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();
Expand Down

0 comments on commit 7fb4ae9

Please sign in to comment.