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.
commit27b70696df78430c5596cb7681be496ac305ec05
authorSkyler Hawthorne <skyler@dead10ck.com>
dateMon 3 Oct 2022, 11:35 (4 years ago)
parent6cca737
helix-term/src/application.rs+8−1
@@ -870,9 +870,16 @@ impl Application {
870870 }));
871871
872872 self.event_loop(input_stream).await;
873− self.close().await?;
873+
874+ let err = self.close().await.err();
875+
874876 restore_term()?;
875877
878+ if let Some(err) = err {
879+ self.editor.exit_code = 1;
880+ eprintln!("Error: {}", err);
881+ }
882+
876883 Ok(self.editor.exit_code)
877884 }
878885