aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-19 02:57:22 +0000
committerBlaž Hrastnik2020-09-19 02:58:08 +0000
commit91343a68461608efa9f45be75a7dcaece0fd65a7 (patch)
treef949dffc4263a4362233440d38d5da3987a8c32f /helix-term
parent929fa5474d5838d4c58dca8b0e576f5add49156b (diff)
Restore terminal mode on panics.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/editor.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index 397ce8df..9b5cad51 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -376,6 +376,14 @@ impl Editor {
execute!(stdout, terminal::EnterAlternateScreen)?;
+ // Exit the alternate screen and disable raw mode before panicking
+ let hook = std::panic::take_hook();
+ std::panic::set_hook(Box::new(move |info| {
+ execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
+ disable_raw_mode();
+ hook(info);
+ }));
+
self.event_loop().await;
// reset cursor shape