diff options
| author | mo8it <mo8it@proton.me> | 2024-09-04 01:05:30 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-09-04 01:05:30 +0200 |
| commit | da8b3d143a5b7462baf912c58cc768f7cd210ab2 (patch) | |
| tree | 993ef0f3d0bec5588e9d8e08a47c8ae487a6b5b7 /src/list.rs | |
| parent | 20616ff954f19551b7a421193ed915fa9a518915 (diff) | |
Final touches to searching
Diffstat (limited to 'src/list.rs')
| -rw-r--r-- | src/list.rs | 16 |
1 files changed, 7 insertions, 9 deletions
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 => (), |
