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 c4bd17d commit 324f3dc
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,6 +1,7 @@
use std::io;
use std::sync::{Arc, RwLock, RwLockWriteGuard};
use std::time::{Duration, Instant};
use std::thread::panicking;

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 324f3dc

Please sign in to comment.