diff --git a/src/list.rs b/src/list.rs index 664932c2..d50ed715 100644 --- a/src/list.rs +++ b/src/list.rs @@ -356,7 +356,15 @@ impl CustomList { self.toggle_preview_window(state); None } - KeyCode::Enter if self.preview_window_state.is_none() => self.handle_enter(), + + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') => { + if self.preview_window_state.is_none() { + self.handle_enter() + } else { + None + } + } + KeyCode::Left | KeyCode::Char('h') if !self.at_root() => self.enter_parent_directory(), _ => None, } } @@ -452,6 +460,12 @@ impl CustomList { None } + fn enter_parent_directory(&mut self) -> Option { + self.visit_stack.pop(); + self.list_state.select(Some(0)); + None + } + /// Handles the key. This key can do 3 things: /// - Run a command, if it is the currently selected item, /// - Go up a directory @@ -469,9 +483,7 @@ impl CustomList { .unwrap(); if !self.at_root() && selected_index == 0 { - self.visit_stack.pop(); - self.list_state.select(Some(0)); - return None; + return self.enter_parent_directory(); } let mut actual_index = selected_index;