From c4897139aeff2316d2b737a4e03b7491b696ce3b Mon Sep 17 00:00:00 2001 From: mo8it Date: Sun, 7 Apr 2024 03:41:23 +0200 Subject: [PATCH] Prevent unneeded redraws --- src/list.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/list.rs b/src/list.rs index 82c3e46..b8ea27b 100644 --- a/src/list.rs +++ b/src/list.rs @@ -80,7 +80,13 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> { let key = loop { match event::read()? { - Event::Key(key) => break key, + Event::Key(key) => { + if key.kind != KeyEventKind::Press { + continue; + } + + break key; + } // Redraw Event::Resize(_, _) => continue 'outer, // Ignore @@ -88,10 +94,6 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> { } }; - if key.kind != KeyEventKind::Press { - continue; - } - match key.code { KeyCode::Char('q') => break, KeyCode::Down | KeyCode::Char('j') => {