From 45c78c6080e9c7d069d487b2795785fbb3f28019 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 2 May 2025 20:00:13 +0800 Subject: [PATCH] Simplify --- yazi-core/src/tab/commands/copy.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/yazi-core/src/tab/commands/copy.rs b/yazi-core/src/tab/commands/copy.rs index eb555897..212dc17a 100644 --- a/yazi-core/src/tab/commands/copy.rs +++ b/yazi-core/src/tab/commands/copy.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, ffi::{OsStr, OsString}, path::Path}; use yazi_plugin::CLIPBOARD; -use yazi_shared::{event::CmdCow, url::Url}; +use yazi_shared::event::CmdCow; use crate::tab::Tab; @@ -29,12 +29,13 @@ impl Tab { } let mut s = OsString::new(); - let mut it = self.selected_or_hovered().peekable(); - if opt.hovered { - if let Some(h) = self.hovered() { - it = (Box::new(vec![&h.url].into_iter()) as Box + '_>).peekable(); - } else { return }; + 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),