Exit gracefully when close operation fails (#4081)

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.
This commit is contained in:
Skyler Hawthorne 2022-10-03 11:35:42 -04:00 committed by GitHub
parent 6cca7375ec
commit 27b70696df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}