mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-19 23:01:36 +03:00
feat: fallback to the enter
behavior when there is only one item selected and its a directory #2
This commit is contained in:
parent
14639f64ac
commit
43e731b9a1
@ -21,8 +21,8 @@ keymap = [
|
||||
{ on = [ "<Up>" ], exec = "arrow -1" },
|
||||
{ on = [ "<Down>" ], exec = "arrow 1" },
|
||||
{ on = [ "<Left>" ], exec = "leave" },
|
||||
{ on = [ "<Right>" ], exec = "open" },
|
||||
{ on = [ "<C-Right>" ], exec = "open --select" },
|
||||
{ on = [ "<Right>" ], exec = "enter" },
|
||||
{ on = [ "<Enter>" ], exec = "open" },
|
||||
|
||||
# Selection
|
||||
{ on = [ "<Space>" ], 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 = [ "<C-r>" ], exec = [ "redo" ] },
|
||||
]
|
||||
|
@ -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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{InputMode, InputSnap};
|
||||
use super::InputSnap;
|
||||
|
||||
#[derive(Default, PartialEq, Eq)]
|
||||
pub(super) struct InputSnaps {
|
||||
|
@ -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()))
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user