on master help sign in
Restore terminal mode on panics.
91343a6Blaž Hrastnik
helix-term/src/editor.rs+8
@@ -376,6 +376,14 @@ impl Editor {
376
376
377 execute!(stdout, terminal::EnterAlternateScreen)?;
377 execute!(stdout, terminal::EnterAlternateScreen)?;
378
378
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+
379 self.event_loop().await;
387 self.event_loop().await;
380
388
381 // reset cursor shape
389 // reset cursor shape