From 10eff07d160bd53c0949fcb66e623687ba01b668 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Fri, 10 Jul 2020 09:43:33 +0000 Subject: [PATCH] Fix another source of flickering When you have many keystrokes in the `stdin` (pushing long keys), we are saying to `termion` to print many things. Throttling this. --- Cargo.lock | 2 +- src/view.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bbe6f51..b3dc2d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,7 +141,7 @@ dependencies = [ [[package]] name = "thumbs" -version = "0.4.1" +version = "0.4.2" dependencies = [ "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/view.rs b/src/view.rs index e3faa98..8416959 100644 --- a/src/view.rs +++ b/src/view.rs @@ -238,10 +238,12 @@ impl<'a> View<'a> { } Err(err) => panic!(err), } + + stdin.keys().for_each(|_| { /* Skip the rest of stdin buffer */ }) } _ => { // Nothing in the buffer. Wait for a bit... - std::thread::sleep(std::time::Duration::from_millis(100)); + std::thread::sleep(std::time::Duration::from_millis(50)); continue; // don't render again if nothing new to show } }