Skip to content

Commit 9056e5e

Browse files
naseschwarzNaseschwarz
and
Naseschwarz
authored
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]>
1 parent 782ec07 commit 9056e5e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/main.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ fn setup_terminal() -> Result<()> {
288288
}
289289

290290
fn shutdown_terminal() {
291+
let mut stdout = io::stdout();
292+
291293
let leave_screen =
292-
io::stdout().execute(LeaveAlternateScreen).map(|_f| ());
294+
stdout.execute(LeaveAlternateScreen).map(|_f| ());
293295

294296
if let Err(e) = leave_screen {
295297
eprintln!("leave_screen failed:\n{e}");
@@ -300,6 +302,10 @@ fn shutdown_terminal() {
300302
if let Err(e) = leave_raw_mode {
301303
eprintln!("leave_raw_mode failed:\n{e}");
302304
}
305+
306+
if let Err(e) = stdout.execute(crossterm::cursor::Show) {
307+
eprintln!("Showing cursor failed:\n{e}");
308+
}
303309
}
304310

305311
fn draw(terminal: &mut Terminal, app: &App) -> io::Result<()> {

0 commit comments

Comments
 (0)