feat: open support enter dir (#2)

This commit is contained in:
fzdwx 2023-07-22 22:53:03 +08:00 committed by GitHub
parent b6ea235b5e
commit f6547dd051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -21,7 +21,8 @@ keymap = [
{ on = [ "<Up>" ], exec = "arrow -1" },
{ on = [ "<Down>" ], exec = "arrow 1" },
{ on = [ "<Left>" ], exec = "leave" },
{ on = [ "<Right>" ], exec = "enter" },
{ on = [ "<Right>" ], exec = "open" },
{ on = [ "<C-Right>" ], exec = "open --select" },
# Selection
{ on = [ "<Space>" ], exec = "select --state=none" },

View File

@ -262,6 +262,16 @@ 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 {

View File

@ -78,7 +78,12 @@ impl Executor {
}
// Operation
"open" => cx.manager.open(exec.named.contains_key("select")),
"open" => {
if cx.manager.active().current_is_dir() {
return cx.manager.active_mut().enter();
}
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();