From 5da39722e4eed4a5185979f8cecdc6c16ce09d4c Mon Sep 17 00:00:00 2001 From: hankertrix <91734413+hankertrix@users.noreply.github.com> Date: Fri, 2 May 2025 12:02:40 +0000 Subject: [PATCH] feat: add `--hovered` to the `copy` command (#2709) Co-authored-by: sxyazi --- yazi-core/src/tab/commands/copy.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index dc028354..212dc17a 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -8,6 +8,7 @@ use crate::tab::Tab; struct Opt { type_: Cow<'static, str>, separator: Separator, + hovered: bool, } impl From for Opt { @@ -15,6 +16,7 @@ impl From for Opt { Self { type_: c.take_first_str().unwrap_or_default(), 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 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() { s.push(match opt.type_.as_ref() { "path" => opt.separator.transform(u),