Skip to content

Commit 27b7069

Browse files
authored
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.
1 parent 6cca737 commit 27b7069

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

helix-term/src/application.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)