diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-07-21 09:58:22 +0800 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-07-21 09:58:22 +0800 |
commit | 8cdc2ea4decf7eceba3e01d67b64c41ab9ddcb26 (patch) | |
tree | f39c3c135c3241e9551c33118c12bd8dd65d082d | |
parent | cb2bbdfe616b38311ebe26e78999c69a4637a5dd (diff) |
Assure we flush stdout to switch back to the previous screen
Previously the TUI would leave the alternate screen where it was,
potentially, as stdout wasn't flushed.
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 20ce001..7fd9867 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,8 +19,6 @@ fn run() -> Result<(), Error> { use options::Command::*; let opt: options::Args = options::Args::from_args(); - let stdout = io::stdout(); - let stdout_locked = stdout.lock(); let walk_options = dua::WalkOptions { threads: opt.threads.unwrap_or(0), byte_format: opt.format.map(Into::into).unwrap_or(ByteFormat::Metric), @@ -42,7 +40,9 @@ fn run() -> Result<(), Error> { Terminal::new(backend)? }; let mut app = TerminalApp::initialize(&mut terminal, walk_options, paths_from(input)?)?; - app.process_events(&mut terminal, io::stdin().keys())? + let res = app.process_events(&mut terminal, io::stdin().keys())?; + io::stdout().flush().ok(); + res } Some(Aggregate { input, @@ -50,6 +50,8 @@ fn run() -> Result<(), Error> { no_sort, statistics, }) => { + let stdout = io::stdout(); + let stdout_locked = stdout.lock(); let (res, stats) = dua::aggregate( stdout_locked, walk_options, @@ -63,6 +65,8 @@ fn run() -> Result<(), Error> { res } None => { + let stdout = io::stdout(); + let stdout_locked = stdout.lock(); dua::aggregate( stdout_locked, walk_options, |