Restore terminal mode on panics.
commit91343a68461608efa9f45be75a7dcaece0fd65a7
authorBlaž Hrastnik <blaz@mxxn.io>
dateSat 19 Sep 2020, 11:57 (6 years ago)
parent929fa54
helix-term/src/editor.rs+8
@@ -376,6 +376,14 @@ impl Editor {
376376
377377 execute!(stdout, terminal::EnterAlternateScreen)?;
378378
379+ // Exit the alternate screen and disable raw mode before panicking
380+ let hook = std::panic::take_hook();
381+ std::panic::set_hook(Box::new(move |info| {
382+ execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
383+ disable_raw_mode();
384+ hook(info);
385+ }));
386+
379387 self.event_loop().await;
380388
381389 // reset cursor shape