Skip to content

Commit

Permalink
Assure we flush stdout to switch back to the previous screen
Browse files Browse the repository at this point in the history
Previously the TUI would leave the alternate screen where it was,
potentially, as stdout wasn't flushed.
  • Loading branch information
Sebastian Thiel committed Jul 21, 2019
1 parent cb2bbdf commit 8cdc2ea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -42,14 +40,18 @@ 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,
no_total,
no_sort,
statistics,
}) => {
let stdout = io::stdout();
let stdout_locked = stdout.lock();
let (res, stats) = dua::aggregate(
stdout_locked,
walk_options,
Expand All @@ -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,
Expand Down

0 comments on commit 8cdc2ea

Please sign in to comment.