From c088820ae84318077e5a37a3bed6d20b3f7aa3f3 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 17 Jan 2024 17:10:24 -0600 Subject: [PATCH] fix(fmt): Ensure stream gets flushed Fixes #278 --- src/fmt/writer/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fmt/writer/mod.rs b/src/fmt/writer/mod.rs index fa7ce1f..ba0ec7e 100644 --- a/src/fmt/writer/mod.rs +++ b/src/fmt/writer/mod.rs @@ -69,17 +69,20 @@ impl WritableTarget { WritableTarget::WriteStdout => { let mut stream = std::io::stdout().lock(); stream.write_all(buf)?; + stream.flush()?; } WritableTarget::PrintStdout => print!("{}", String::from_utf8_lossy(buf)), WritableTarget::WriteStderr => { let mut stream = std::io::stderr().lock(); stream.write_all(buf)?; + stream.flush()?; } WritableTarget::PrintStderr => eprint!("{}", String::from_utf8_lossy(buf)), // Safety: If the target type is `Pipe`, `target_pipe` will always be non-empty. WritableTarget::Pipe(pipe) => { let mut stream = pipe.lock().unwrap(); stream.write_all(buf)?; + stream.flush()?; } }