From a8b68f8dd806eb3b73ef9d80f214648d050538e0 Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:15:57 -0700 Subject: [PATCH] refactor: Improve formatting of key handling match statement --- src/list.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/list.rs b/src/list.rs index 4bf11d55..e5eacde5 100644 --- a/src/list.rs +++ b/src/list.rs @@ -259,10 +259,10 @@ impl CustomList { // so the scroll does not happen in the main window as well if self.preview_window_state.is_some() { self.scroll_preview_window_down(); - return None; + } else { + self.list_state.select_next(); } - self.list_state.select_next(); None } KeyCode::Char('k') | KeyCode::Up => { @@ -270,10 +270,10 @@ impl CustomList { // so the scroll does not happen in the main window as well if self.preview_window_state.is_some() { self.scroll_preview_window_up(); - return None; + } else { + self.list_state.select_previous(); } - self.list_state.select_previous(); None } // The 'p' key toggles the preview on and off @@ -281,14 +281,7 @@ impl CustomList { self.toggle_preview_window(state); None } - - KeyCode::Enter => { - if self.preview_window_state.is_none() { - self.handle_enter() - } else { - None - } - } + KeyCode::Enter if self.preview_window_state.is_none() => self.handle_enter(), _ => None, } }