diff --git a/yazi-core/src/manager/commands/paste.rs b/yazi-core/src/manager/commands/paste.rs index 876196cd..7661bd69 100644 --- a/yazi-core/src/manager/commands/paste.rs +++ b/yazi-core/src/manager/commands/paste.rs @@ -1,4 +1,3 @@ -use yazi_dds::Pubsub; use yazi_shared::event::Cmd; use crate::{manager::Manager, tasks::Tasks}; @@ -22,12 +21,6 @@ impl Manager { if self.yanked.cut { tasks.file_cut(&src, dest, opt.force); - src.iter().for_each(|source_file| { - if let Some(name) = source_file.file_name().map(|s| dest.join(s)) { - Pubsub::pub_from_move(self.tabs.cursor, source_file, &name); - } - }); - self.tabs.iter_mut().for_each(|t| _ = t.selected.remove_many(&src, false)); self.unyank(()); } else { diff --git a/yazi-dds/src/body/move_.rs b/yazi-dds/src/body/move_.rs index 64188240..f49ee15d 100644 --- a/yazi-dds/src/body/move_.rs +++ b/yazi-dds/src/body/move_.rs @@ -8,22 +8,21 @@ use super::Body; #[derive(Debug, Serialize, Deserialize)] pub struct BodyMove<'a> { - pub tab: usize, pub from: Cow<'a, Url>, pub to: Cow<'a, Url>, } impl<'a> BodyMove<'a> { #[inline] - pub fn borrowed(tab: usize, from: &'a Url, to: &'a Url) -> Body<'a> { - Self { tab, from: Cow::Borrowed(from), to: Cow::Borrowed(to) }.into() + pub fn borrowed(from: &'a Url, to: &'a Url) -> Body<'a> { + Self { from: Cow::Borrowed(from), to: Cow::Borrowed(to) }.into() } } impl BodyMove<'static> { #[inline] - pub fn dummy(tab: usize, from: &Url, to: &Url) -> Body<'static> { - Self { tab, from: Cow::Owned(from.clone()), to: Cow::Owned(to.clone()) }.into() + pub fn dummy(from: &Url, to: &Url) -> Body<'static> { + Self { from: Cow::Owned(from.clone()), to: Cow::Owned(to.clone()) }.into() } } @@ -37,7 +36,6 @@ impl IntoLua<'_> for BodyMove<'static> { fn into_lua(self, lua: &Lua) -> mlua::Result { lua .create_table_from([ - ("tab", self.tab.into_lua(lua)?), ("from", lua.create_any_userdata(self.from.into_owned())?.into_lua(lua)?), ("to", lua.create_any_userdata(self.to.into_owned())?.into_lua(lua)?), ])? diff --git a/yazi-dds/src/pubsub.rs b/yazi-dds/src/pubsub.rs index 76c76e04..e35598fa 100644 --- a/yazi-dds/src/pubsub.rs +++ b/yazi-dds/src/pubsub.rs @@ -150,15 +150,15 @@ impl Pubsub { } } - pub fn pub_from_move(tab: usize, from: &Url, to: &Url) { + pub fn pub_from_move(from: &Url, to: &Url) { if LOCAL.read().contains_key("move") { - Self::pub_(BodyMove::dummy(tab, from, to)); + Self::pub_(BodyMove::dummy(from, to)); } if PEERS.read().values().any(|p| p.able("move")) { - Client::push(BodyMove::borrowed(tab, from, to)); + Client::push(BodyMove::borrowed(from, to)); } if BOOT.local_events.contains("move") { - BodyMove::borrowed(tab, from, to).with_receiver(*ID).flush(); + BodyMove::borrowed(from, to).with_receiver(*ID).flush(); } } } diff --git a/yazi-scheduler/src/file/file.rs b/yazi-scheduler/src/file/file.rs index 4a9fb53c..534cbdb1 100644 --- a/yazi-scheduler/src/file/file.rs +++ b/yazi-scheduler/src/file/file.rs @@ -5,6 +5,7 @@ use futures::{future::BoxFuture, FutureExt}; use tokio::{fs, io::{self, ErrorKind::{AlreadyExists, NotFound}}, sync::mpsc}; use tracing::warn; use yazi_config::TASKS; +use yazi_dds::Pubsub; use yazi_shared::fs::{accessible, calculate_size, copy_with_progress, path_relative_to, Url}; use super::{FileOp, FileOpDelete, FileOpLink, FileOpPaste, FileOpTrash}; @@ -37,6 +38,7 @@ impl File { Ok(0) => { if task.cut { fs::remove_file(&task.from).await.ok(); + Pubsub::pub_from_move(&task.from, &task.to); } break; }