Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ async fn main() -> AppResult<()> {

tui.init()?;

// Run the app, but always restore the terminal afterwards so a failure
// does not leave the user's terminal in raw mode. Prioritize the run
// error so a failing exit() does not mask the real cause.
let result = run(&mut tui, config).await;
let exit_result = tui.exit();
result.and(exit_result)
}

async fn run(tui: &mut Tui<CrosstermBackend<io::Stdout>>, config: Arc<Config>) -> AppResult<()> {
let mut app = App::new(config.clone(), tui.events.sender.clone()).await?;

while app.running {
Expand Down Expand Up @@ -145,6 +154,5 @@ async fn main() -> AppResult<()> {
}
}

tui.exit()?;
Ok(())
}