Skip to content

Commit

Permalink
Exit gracefully when close operation fails (helix-editor#4081)
Browse files Browse the repository at this point in the history
If the close method fails, the editor will quit before restoring the
terminal. This causes the shell to break if, e.g. the LS times out
shutting down.

This fixes this by always restoring the terminal after closing, and
printing out a message to stderr if there is an error.
  • Loading branch information
dead10ck authored and pathwave committed Nov 4, 2022
1 parent 216f485 commit 45e881f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,16 @@ impl Application {
}));

self.event_loop(input_stream).await;
self.close().await?;

let err = self.close().await.err();

restore_term()?;

if let Some(err) = err {
self.editor.exit_code = 1;
eprintln!("Error: {}", err);
}

Ok(self.editor.exit_code)
}

Expand Down

0 comments on commit 45e881f

Please sign in to comment.