Skip to content

Commit 17751a7

Browse files
committed
refactor: moved the if statements inside the match case
1 parent 28287ae commit 17751a7

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/event.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,15 @@ pub fn handle_key_event_or_break(
5656
// c_debug!("KeyEvent: {event:?}");
5757

5858
if event.modifiers.is_empty() {
59-
// Required catch for searching - otherwise you couldn't search with q.
60-
if event.code == KeyCode::Char('q') && !app.is_in_search_widget() {
61-
return true;
62-
}
63-
64-
// Handle spacebar.
65-
// Without the search check, you couldn’t search for names with spaces.
66-
if event.code == KeyCode::Char(' ') && !app.is_in_search_widget() {
67-
app.toggle_tree_mode();
68-
return false;
69-
}
70-
7159
match event.code {
60+
KeyCode::Char('q') if !app.is_in_search_widget() => return true,
7261
KeyCode::End => app.skip_to_last(),
7362
KeyCode::Home => app.skip_to_first(),
7463
KeyCode::Up => app.on_up_key(),
7564
KeyCode::Down => app.on_down_key(),
7665
KeyCode::Left => app.on_left_key(),
7766
KeyCode::Right => app.on_right_key(),
67+
KeyCode::Char(' ') if !app.is_in_search_widget() => app.toggle_tree_mode(),
7868
KeyCode::Char(caught_char) => app.on_char_key(caught_char),
7969
KeyCode::Esc => app.on_esc(),
8070
KeyCode::Enter => app.on_enter(),

0 commit comments

Comments
 (0)