diff --git a/config/keymap.toml b/config/keymap.toml index dfd4c670..1cb7783b 100644 --- a/config/keymap.toml +++ b/config/keymap.toml @@ -21,8 +21,8 @@ keymap = [ { on = [ "" ], exec = "arrow -1" }, { on = [ "" ], exec = "arrow 1" }, { on = [ "" ], exec = "leave" }, - { on = [ "" ], exec = "open" }, - { on = [ "" ], exec = "open --select" }, + { on = [ "" ], exec = "enter" }, + { on = [ "" ], exec = "open" }, # Selection { on = [ "" ], exec = "select --state=none" }, @@ -135,5 +135,8 @@ keymap = [ { on = [ "y" ], exec = [ "yank" ] }, { on = [ "p" ], exec = [ "paste" ] }, - { on = [ "P" ], exec = [ "paste --before" ] } + { on = [ "P" ], exec = [ "paste --before" ] }, + + { on = [ "u" ], exec = [ "undo" ] }, + { on = [ "" ], exec = [ "redo" ] }, ] diff --git a/docs/keymap.md b/docs/keymap.md index ec980f9f..9bcee8e1 100644 --- a/docs/keymap.md +++ b/docs/keymap.md @@ -145,6 +145,9 @@ - `--before`: Paste the copied characters before the cursor. +- undo: Undo the last operation. +- redo: Redo the last operation. + ### Insert mode - close: Cancel input. diff --git a/src/core/input/snaps.rs b/src/core/input/snaps.rs index 63520ca0..45fe09e5 100644 --- a/src/core/input/snaps.rs +++ b/src/core/input/snaps.rs @@ -1,4 +1,4 @@ -use super::{InputMode, InputSnap}; +use super::InputSnap; #[derive(Default, PartialEq, Eq)] pub(super) struct InputSnaps { diff --git a/src/core/manager/manager.rs b/src/core/manager/manager.rs index 8a2d2522..c362495f 100644 --- a/src/core/manager/manager.rs +++ b/src/core/manager/manager.rs @@ -113,8 +113,12 @@ impl Manager { } pub fn open(&mut self, select: bool) -> bool { - let mut files = self - .selected() + let files = self.selected(); + if files.len() == 1 && files[0].meta.is_dir() { + return self.active_mut().enter(); + } + + let mut files = files .into_iter() .filter(|f| f.meta.is_file()) .map(|f| (f.path(), self.mimetype.get(&f.path).cloned())) diff --git a/src/core/manager/tab.rs b/src/core/manager/tab.rs index e88deee5..e492ee1e 100644 --- a/src/core/manager/tab.rs +++ b/src/core/manager/tab.rs @@ -262,16 +262,6 @@ impl Tab { }; true } - - pub fn current_is_dir(&self) -> bool{ - let hovered = if let Some(ref h) = self.current.hovered { - h.clone() - } else { - return false; - }; - - hovered.meta.is_dir() - } } impl Tab { diff --git a/src/ui/dispatcher.rs b/src/ui/dispatcher.rs index d90ecb42..6ce822db 100644 --- a/src/ui/dispatcher.rs +++ b/src/ui/dispatcher.rs @@ -78,12 +78,7 @@ impl Executor { } // Operation - "open" => { - if cx.manager.active().current_is_dir() { - return cx.manager.active_mut().enter(); - } - cx.manager.open(exec.named.contains_key("select")) - }, + "open" => cx.manager.open(exec.named.contains_key("select")), "yank" => cx.manager.yank(exec.named.contains_key("cut")), "paste" => { let dest = cx.manager.current().cwd.clone();