From 16f9e5d36c6aec6817e5569f490d45febc79292e Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:08:38 -0700 Subject: [PATCH 1/2] feat: Allow navigation with 'h' and 'l' keys --- src/list.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/list.rs b/src/list.rs index 4bf11d55..abdde50e 100644 --- a/src/list.rs +++ b/src/list.rs @@ -282,13 +282,14 @@ impl CustomList { None } - KeyCode::Enter => { + KeyCode::Enter | KeyCode::Char('l') => { if self.preview_window_state.is_none() { self.handle_enter() } else { None } } + KeyCode::Char('h') if !self.at_root() => self.enter_parent_directory(), _ => None, } } @@ -384,6 +385,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 @@ -401,9 +408,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; From 8aa7a216abb655a2c8c528e72ed01fc7d4782cfc Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:11:43 -0700 Subject: [PATCH 2/2] feat: Add right/left arrow key navigation --- src/list.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/list.rs b/src/list.rs index abdde50e..90a4f265 100644 --- a/src/list.rs +++ b/src/list.rs @@ -282,14 +282,14 @@ impl CustomList { None } - KeyCode::Enter | KeyCode::Char('l') => { + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') => { if self.preview_window_state.is_none() { self.handle_enter() } else { None } } - KeyCode::Char('h') if !self.at_root() => self.enter_parent_directory(), + KeyCode::Left | KeyCode::Char('h') if !self.at_root() => self.enter_parent_directory(), _ => None, } }