Prevent unneeded redraws

This commit is contained in:
mo8it 2024-04-07 03:41:23 +02:00
parent 372290a796
commit c4897139ae

View file

@ -80,7 +80,13 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> {
let key = loop { let key = loop {
match event::read()? { match event::read()? {
Event::Key(key) => break key, Event::Key(key) => {
if key.kind != KeyEventKind::Press {
continue;
}
break key;
}
// Redraw // Redraw
Event::Resize(_, _) => continue 'outer, Event::Resize(_, _) => continue 'outer,
// Ignore // Ignore
@ -88,10 +94,6 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> {
} }
}; };
if key.kind != KeyEventKind::Press {
continue;
}
match key.code { match key.code {
KeyCode::Char('q') => break, KeyCode::Char('q') => break,
KeyCode::Down | KeyCode::Char('j') => { KeyCode::Down | KeyCode::Char('j') => {