mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 13:22:28 +00:00
feat: Allow navigation with 'h' and 'l' keys
This commit is contained in:
parent
6f865f76ef
commit
16f9e5d36c
13
src/list.rs
13
src/list.rs
|
@ -282,13 +282,14 @@ impl CustomList {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyCode::Enter => {
|
KeyCode::Enter | KeyCode::Char('l') => {
|
||||||
if self.preview_window_state.is_none() {
|
if self.preview_window_state.is_none() {
|
||||||
self.handle_enter()
|
self.handle_enter()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
KeyCode::Char('h') if !self.at_root() => self.enter_parent_directory(),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,6 +385,12 @@ impl CustomList {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn enter_parent_directory(&mut self) -> Option<Command> {
|
||||||
|
self.visit_stack.pop();
|
||||||
|
self.list_state.select(Some(0));
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles the <Enter> key. This key can do 3 things:
|
/// Handles the <Enter> key. This key can do 3 things:
|
||||||
/// - Run a command, if it is the currently selected item,
|
/// - Run a command, if it is the currently selected item,
|
||||||
/// - Go up a directory
|
/// - Go up a directory
|
||||||
|
@ -401,9 +408,7 @@ impl CustomList {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
if !self.at_root() && selected_index == 0 {
|
if !self.at_root() && selected_index == 0 {
|
||||||
self.visit_stack.pop();
|
return self.enter_parent_directory();
|
||||||
self.list_state.select(Some(0));
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut actual_index = selected_index;
|
let mut actual_index = selected_index;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user