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 <[email protected]>
This commit is contained in:
Johannes Agricola
2025-04-18 09:53:25 +02:00
committed by GitHub
co-authored by Naseschwarz
parent 782ec070b4
commit 9056e5e75c
+7 -1
View File
@@ -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<()> {