From 1d299b053344687dd86c79f5bdee3db5a6e8b4d2 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 6 Jul 2025 22:25:51 +0800 Subject: [PATCH] .. --- yazi-core/src/mgr/commands/watch.rs | 2 +- yazi-core/src/mgr/watcher.rs | 2 +- yazi-parser/src/input/escape.rs | 12 +----------- yazi-parser/src/lib.rs | 2 ++ yazi-parser/src/mgr/unyank.rs | 12 +----------- yazi-parser/src/mgr/watch.rs | 12 +----------- yazi-parser/src/spot/close.rs | 12 +----------- yazi-parser/src/tab/follow.rs | 8 +------- yazi-parser/src/tab/leave.rs | 12 +----------- yazi-parser/src/tasks/close.rs | 12 +----------- yazi-parser/src/tasks/show.rs | 12 +----------- yazi-parser/src/void.rs | 11 +++++++++++ 12 files changed, 23 insertions(+), 86 deletions(-) create mode 100644 yazi-parser/src/void.rs diff --git a/yazi-core/src/mgr/commands/watch.rs b/yazi-core/src/mgr/commands/watch.rs index 07fe2ad4..154318e4 100644 --- a/yazi-core/src/mgr/commands/watch.rs +++ b/yazi-core/src/mgr/commands/watch.rs @@ -6,7 +6,7 @@ use crate::mgr::Mgr; impl Mgr { #[yazi_codegen::command] - pub fn watch(&mut self, _: Opt) { + pub fn watch(&mut self, _: WatchOpt) { let it = iter::once(self.tabs.active().cwd()) .chain(self.tabs.parent().map(|p| &p.url)) .chain(self.tabs.hovered().filter(|h| h.is_dir()).map(|h| &h.url)); diff --git a/yazi-core/src/mgr/watcher.rs b/yazi-core/src/mgr/watcher.rs index c8577692..0ef4eaee 100644 --- a/yazi-core/src/mgr/watcher.rs +++ b/yazi-core/src/mgr/watcher.rs @@ -52,7 +52,7 @@ impl Watcher { } pub(super) fn watch<'a>(&mut self, it: impl Iterator) { - self.in_tx.send(it.into_iter().filter(|u| u.is_regular()).cloned().collect()).ok(); + self.in_tx.send(it.filter(|u| u.is_regular()).cloned().collect()).ok(); } pub(super) fn push_files(&self, urls: Vec) { diff --git a/yazi-parser/src/input/escape.rs b/yazi-parser/src/input/escape.rs index 8f6b5301..eae3a61a 100644 --- a/yazi-parser/src/input/escape.rs +++ b/yazi-parser/src/input/escape.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct EscapeOpt; - -impl From for EscapeOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for EscapeOpt { - fn from(_: ()) -> Self { Self } -} +pub type EscapeOpt = crate::VoidOpt; diff --git a/yazi-parser/src/lib.rs b/yazi-parser/src/lib.rs index af0da039..6806895d 100644 --- a/yazi-parser/src/lib.rs +++ b/yazi-parser/src/lib.rs @@ -1 +1,3 @@ yazi_macro::mod_pub!(cmp confirm help input mgr notify pick spot tab tasks which); + +yazi_macro::mod_flat!(void); diff --git a/yazi-parser/src/mgr/unyank.rs b/yazi-parser/src/mgr/unyank.rs index ce6a154e..b2575fae 100644 --- a/yazi-parser/src/mgr/unyank.rs +++ b/yazi-parser/src/mgr/unyank.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct UnyankOpt; - -impl From for UnyankOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for UnyankOpt { - fn from(_: ()) -> Self { Self } -} +pub type UnyankOpt = crate::VoidOpt; diff --git a/yazi-parser/src/mgr/watch.rs b/yazi-parser/src/mgr/watch.rs index 5bc2ca3a..a4217560 100644 --- a/yazi-parser/src/mgr/watch.rs +++ b/yazi-parser/src/mgr/watch.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct WatchOpt; - -impl From for WatchOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for WatchOpt { - fn from((): ()) -> Self { Self } -} +pub type WatchOpt = crate::VoidOpt; diff --git a/yazi-parser/src/spot/close.rs b/yazi-parser/src/spot/close.rs index 59462296..d6b58a69 100644 --- a/yazi-parser/src/spot/close.rs +++ b/yazi-parser/src/spot/close.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct CloseOpt; - -impl From for CloseOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for CloseOpt { - fn from(_: ()) -> Self { Self } -} +pub type CloseOpt = crate::VoidOpt; diff --git a/yazi-parser/src/tab/follow.rs b/yazi-parser/src/tab/follow.rs index 2edc8b92..c5fd9e27 100644 --- a/yazi-parser/src/tab/follow.rs +++ b/yazi-parser/src/tab/follow.rs @@ -1,7 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct FollowOpt; - -impl From for FollowOpt { - fn from(_: CmdCow) -> Self { Self } -} +pub type FollowOpt = crate::VoidOpt; diff --git a/yazi-parser/src/tab/leave.rs b/yazi-parser/src/tab/leave.rs index 62c868cf..04c4b82e 100644 --- a/yazi-parser/src/tab/leave.rs +++ b/yazi-parser/src/tab/leave.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct LeaveOpt; - -impl From<()> for LeaveOpt { - fn from(_: ()) -> Self { Self } -} - -impl From for LeaveOpt { - fn from(_: CmdCow) -> Self { Self } -} +pub type LeaveOpt = crate::VoidOpt; diff --git a/yazi-parser/src/tasks/close.rs b/yazi-parser/src/tasks/close.rs index 59462296..d6b58a69 100644 --- a/yazi-parser/src/tasks/close.rs +++ b/yazi-parser/src/tasks/close.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct CloseOpt; - -impl From for CloseOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for CloseOpt { - fn from(_: ()) -> Self { Self } -} +pub type CloseOpt = crate::VoidOpt; diff --git a/yazi-parser/src/tasks/show.rs b/yazi-parser/src/tasks/show.rs index 7cf9070c..106b02ad 100644 --- a/yazi-parser/src/tasks/show.rs +++ b/yazi-parser/src/tasks/show.rs @@ -1,11 +1 @@ -use yazi_shared::event::CmdCow; - -pub struct ShowOpt; - -impl From for ShowOpt { - fn from(_: CmdCow) -> Self { Self } -} - -impl From<()> for ShowOpt { - fn from(_: ()) -> Self { Self } -} +pub type ShowOpt = crate::VoidOpt; diff --git a/yazi-parser/src/void.rs b/yazi-parser/src/void.rs new file mode 100644 index 00000000..fd9f98bf --- /dev/null +++ b/yazi-parser/src/void.rs @@ -0,0 +1,11 @@ +use yazi_shared::event::CmdCow; + +pub struct VoidOpt; + +impl From for VoidOpt { + fn from(_: CmdCow) -> Self { Self } +} + +impl From<()> for VoidOpt { + fn from(_: ()) -> Self { Self } +}