diff options
Diffstat (limited to 'src/main/rust/main.rs')
| -rw-r--r-- | src/main/rust/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/rust/main.rs b/src/main/rust/main.rs index 043702c..dad7f7c 100644 --- a/src/main/rust/main.rs +++ b/src/main/rust/main.rs @@ -55,7 +55,11 @@ fn run_app<B: Backend>(term: &mut Terminal<B>, app: &mut App) -> Result<()> { // it's important to check that the event is a key press event as // crossterm also emits key release and repeat events on Windows. Event::Key(key_event) if key_event.kind == KeyEventKind::Press => { - handle_key_event(app, key_event)?; + // if error occurred during input processing, set error in the app state + match handle_key_event(app, key_event) { + Err(e) => app.set_error(e)?, + _ => {} + } } _ => {} }; @@ -71,6 +75,8 @@ fn handle_key_event(app: &mut App, key_event: KeyEvent) -> Result<()> { KeyCode::Right => app.increment_counter()?, _ => {} }; + // any new key event, we should clear the existing error + app.clear_error()?; Ok(()) } |
