correction + regexp
This commit is contained in:
40
src/main.rs
40
src/main.rs
@ -58,14 +58,10 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
}
|
||||
|
||||
match app.mode {
|
||||
// Dans la boucle, Mode::Normal :
|
||||
Mode::Normal => {
|
||||
match key.code {
|
||||
KeyCode::Char('d') | KeyCode::Char('g') => {}
|
||||
_ => {
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
}
|
||||
// FIX: les deux blocs match étaient redondants et mal nommés.
|
||||
// On fusionne la logique en un seul bloc clair.
|
||||
match key.code {
|
||||
KeyCode::Enter => app.paste_selected(),
|
||||
KeyCode::Char('j') | KeyCode::Down => app.next(),
|
||||
@ -76,8 +72,11 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
app.list_state.select(Some(l));
|
||||
app.update_preview();
|
||||
}
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('g') => {
|
||||
last_d = false;
|
||||
if last_g {
|
||||
if !app.filtered_items.is_empty() {
|
||||
app.list_state.select(Some(0));
|
||||
@ -89,6 +88,7 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
}
|
||||
}
|
||||
KeyCode::Char('d') => {
|
||||
last_g = false;
|
||||
if last_d {
|
||||
app.mode = Mode::ConfirmDelete;
|
||||
last_d = false;
|
||||
@ -96,19 +96,39 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
last_d = true;
|
||||
}
|
||||
}
|
||||
KeyCode::Char('u') => app.undo_delete(),
|
||||
KeyCode::Char('e') => app.toggle_encrypt(),
|
||||
KeyCode::Char('u') => {
|
||||
app.undo_delete();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('e') => {
|
||||
app.toggle_encrypt();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('t') => {
|
||||
app.cycle_type_filter();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('/') => {
|
||||
app.mode = Mode::Search;
|
||||
app.input_buffer.clear();
|
||||
app.update_search();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char(':') => {
|
||||
app.mode = Mode::Command;
|
||||
app.input_buffer.clear();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('q') => app.should_quit = true,
|
||||
_ => {}
|
||||
_ => {
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user