Skip to content

Commit

Permalink
fix: more reliable panic printing
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Oct 14, 2024
1 parent 6c85fcd commit 864c5f0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,13 @@ where
let mut stdout = io::stdout();
restore_terminal_state(&mut stdout);
_ = stdout.flush();
println!("{panic_info}");
_ = stdout.flush();

// Restoring the terminal state to move us off of the alternate screen
// can race with our attempt to print the panic info so given that we
// are already in a fatal situation, sleeping briefly to ensure that
// the cause of the panic is visible before we exit isn't _too_ bad.
std::thread::sleep(std::time::Duration::from_millis(300));
eprintln!("Fatal error:\n{panic_info}");
}));

enable_mouse_support(&mut self.stdout);
Expand Down

0 comments on commit 864c5f0

Please sign in to comment.