From da8b3d143a5b7462baf912c58cc768f7cd210ab2 Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 4 Sep 2024 01:05:30 +0200 Subject: Final touches to searching --- src/list.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/list.rs') diff --git a/src/list.rs b/src/list.rs index 5d7c8dd..5e30384 100644 --- a/src/list.rs +++ b/src/list.rs @@ -33,26 +33,24 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()> list_state.message.clear(); - let curr_key = key.code; - if is_searching { - match curr_key { + match key.code { KeyCode::Esc | KeyCode::Enter => { is_searching = false; list_state.search_query.clear(); } - KeyCode::Char(k) => { - list_state.search_query.push(k); + KeyCode::Char(c) => { + list_state.search_query.push(c); list_state.apply_search_query(); - list_state.draw(stdout)?; } KeyCode::Backspace => { list_state.search_query.pop(); list_state.apply_search_query(); - list_state.draw(stdout)?; } - _ => {} + _ => continue, } + + list_state.draw(stdout)?; continue; } @@ -91,8 +89,8 @@ fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()> } } KeyCode::Char('s' | '/') => { - list_state.message.push_str("search:|"); is_searching = true; + list_state.apply_search_query(); } // Redraw to remove the message. KeyCode::Esc => (), -- cgit v1.2.3