mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add --hovered to the copy command (#2709)
Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
parent
37e8747c01
commit
5da39722e4
1 changed files with 9 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ use crate::tab::Tab;
|
||||||
struct Opt {
|
struct Opt {
|
||||||
type_: Cow<'static, str>,
|
type_: Cow<'static, str>,
|
||||||
separator: Separator,
|
separator: Separator,
|
||||||
|
hovered: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CmdCow> for Opt {
|
impl From<CmdCow> for Opt {
|
||||||
|
|
@ -15,6 +16,7 @@ impl From<CmdCow> for Opt {
|
||||||
Self {
|
Self {
|
||||||
type_: c.take_first_str().unwrap_or_default(),
|
type_: c.take_first_str().unwrap_or_default(),
|
||||||
separator: c.str("separator").unwrap_or_default().into(),
|
separator: c.str("separator").unwrap_or_default().into(),
|
||||||
|
hovered: c.bool("hovered"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +29,13 @@ impl Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut s = OsString::new();
|
let mut s = OsString::new();
|
||||||
let mut it = self.selected_or_hovered().peekable();
|
let mut it = if opt.hovered {
|
||||||
|
Box::new(self.hovered().map(|h| &h.url).into_iter())
|
||||||
|
} else {
|
||||||
|
self.selected_or_hovered()
|
||||||
|
}
|
||||||
|
.peekable();
|
||||||
|
|
||||||
while let Some(u) = it.next() {
|
while let Some(u) = it.next() {
|
||||||
s.push(match opt.type_.as_ref() {
|
s.push(match opt.type_.as_ref() {
|
||||||
"path" => opt.separator.transform(u),
|
"path" => opt.separator.transform(u),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue