Fix: / and q are treated as character in search

This commit is contained in:
SoapyDev 2024-08-04 18:25:44 -04:00
parent 6f865f76ef
commit d9b0f84156

View File

@ -142,15 +142,6 @@ fn run<B: Backend>(terminal: &mut Terminal<B>, state: &AppState) -> io::Result<(
command_opt = None; command_opt = None;
} }
} else { } else {
if key.code == KeyCode::Char('q') {
return Ok(());
}
//Activate search mode if the forward slash key gets pressed
if key.code == KeyCode::Char('/') {
// Enter search mode
in_search_mode = true;
continue;
}
//Insert user input into the search bar //Insert user input into the search bar
if in_search_mode { if in_search_mode {
match key.code { match key.code {
@ -175,6 +166,19 @@ fn run<B: Backend>(terminal: &mut Terminal<B>, state: &AppState) -> io::Result<(
} }
} else if let Some(cmd) = custom_list.handle_key(key, state) { } else if let Some(cmd) = custom_list.handle_key(key, state) {
command_opt = Some(RunningCommand::new(cmd, state)); command_opt = Some(RunningCommand::new(cmd, state));
} else {
// Handle keys while not in search mode
match key.code {
// Exit the program
KeyCode::Char('q') => return Ok(()),
//Activate search mode if the forward slash key gets pressed
KeyCode::Char('/') => {
in_search_mode = true;
continue;
},
_ => {}
}
} }
} }
} }