From ac97a31bd75a751fbdbadb9a99de012f68f8e7b8 Mon Sep 17 00:00:00 2001
From: Steven Stanfield <stanfield@scarecrowtech.com>
Date: Thu, 4 Jul 2019 20:21:41 +0000
Subject: [PATCH] Flush outputs before prompt, maybe not best way to fix this?

---
 src/binary/mod.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/binary/mod.rs b/src/binary/mod.rs
index a770e20d..3bfa1aa0 100644
--- a/src/binary/mod.rs
+++ b/src/binary/mod.rs
@@ -187,9 +187,6 @@ impl<'a> InteractiveShell<'a> {
                 }
                 None => {
                     print!("{}", context_bis.borrow().history.buffers.iter().format("\n"));
-                    io::stdout().flush().unwrap_or_else(|err| {
-                        eprintln!("ion: history print: {}", err);
-                    });
                 }
             }
             Status::SUCCESS
@@ -251,6 +248,12 @@ impl<'a> InteractiveShell<'a> {
 
     fn exec<T: Fn(&mut Shell<'_>)>(self, prep_for_exit: &T) -> ! {
         loop {
+            io::stdout().flush().unwrap_or_else(|err| {
+                eprintln!("ion: failed to flush stdio: {}", err);
+            });
+            io::stderr().flush().unwrap_or_else(|err| {
+                println!("ion: failed to flush stderr: {}", err);
+            });
             let mut lines = std::iter::repeat_with(|| self.readln(prep_for_exit))
                 .filter_map(|cmd| cmd)
                 .flat_map(|s| s.into_bytes().into_iter().chain(Some(b'\n')));
-- 
GitLab