Skip to content

Commit

Permalink
Don't write to terminal while panicking
Browse files Browse the repository at this point in the history
This might hide the panic output, making it extremely confusing
how the process might have ended.
  • Loading branch information
djc committed Mar 21, 2022
1 parent 7c0ee52 commit 4bcd612
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/draw_target.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::io;
use std::sync::{Arc, RwLock, RwLockWriteGuard};
use std::thread::panicking;
use std::time::{Duration, Instant};

use console::Term;
Expand Down Expand Up @@ -378,6 +379,10 @@ impl DrawState {
term: &(impl TermLike + ?Sized),
last_line_count: &mut usize,
) -> io::Result<()> {
if panicking() {
return Ok(());
}

if !self.lines.is_empty() && self.move_cursor {
term.move_cursor_up(*last_line_count)?;
} else {
Expand Down

0 comments on commit 4bcd612

Please sign in to comment.