From 9056e5e75cca02c8605c3fc318e460ea061c8bb0 Mon Sep 17 00:00:00 2001 From: Johannes Agricola Date: Fri, 18 Apr 2025 09:53:25 +0200 Subject: [PATCH] Show cursor on panic (#2620) ratatui::Terminal starts by hiding the cursor. If we panic and abort, that Terminal instance is not dropped, which leaves restoring the cursor state to us. Co-authored-by: Naseschwarz --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index feea8944..524261d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -288,8 +288,10 @@ fn setup_terminal() -> Result<()> { } fn shutdown_terminal() { + let mut stdout = io::stdout(); + let leave_screen = - io::stdout().execute(LeaveAlternateScreen).map(|_f| ()); + stdout.execute(LeaveAlternateScreen).map(|_f| ()); if let Err(e) = leave_screen { eprintln!("leave_screen failed:\n{e}"); @@ -300,6 +302,10 @@ fn shutdown_terminal() { if let Err(e) = leave_raw_mode { eprintln!("leave_raw_mode failed:\n{e}"); } + + if let Err(e) = stdout.execute(crossterm::cursor::Show) { + eprintln!("Showing cursor failed:\n{e}"); + } } fn draw(terminal: &mut Terminal, app: &App) -> io::Result<()> {