diff options
author | ebroto <ebroto@tutanota.com> | 2019-12-30 21:15:42 +0100 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2019-12-30 21:15:42 +0100 |
commit | a935397e66c96d989e7b81157ee603b0a58664d2 (patch) | |
tree | 88b21b3e9e6045f0a53f534910108da7c452c185 | |
parent | c9b9025577d0e1f831c9ebb054a5ac00b7a89796 (diff) |
fix(display): avoid panic if render takes more than 1 sec (#41)
-rw-r--r-- | src/main.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 66a3361..dc8c4c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,8 @@ use ::tui::backend::TermionBackend; use structopt::StructOpt; +const DISPLAY_DELTA: time::Duration = time::Duration::from_millis(1000); + #[derive(StructOpt, Debug)] #[structopt(name = "what")] pub struct Opt { @@ -158,7 +160,9 @@ where } } let render_duration = render_start_time.elapsed(); - park_timeout(time::Duration::from_millis(1000) - render_duration); + if render_duration < DISPLAY_DELTA { + park_timeout(DISPLAY_DELTA - render_duration); + } } if !raw_mode { let mut ui = ui.lock().unwrap(); |