diff --git a/yazi-dds/src/body/body.rs b/yazi-dds/src/body/body.rs index 6bbfdd14..ff123996 100644 --- a/yazi-dds/src/body/body.rs +++ b/yazi-dds/src/body/body.rs @@ -32,7 +32,7 @@ impl Body<'static> { "hover" => Self::Hover(serde_json::from_str(body)?), "rename" => Self::Rename(serde_json::from_str(body)?), "bulk" => Self::Bulk(serde_json::from_str(body)?), - "yank" => Self::Yank(serde_json::from_str(body)?), + "@yank" => Self::Yank(serde_json::from_str(body)?), "move" => Self::Move(serde_json::from_str(body)?), "trash" => Self::Trash(serde_json::from_str(body)?), "delete" => Self::Delete(serde_json::from_str(body)?), @@ -55,7 +55,7 @@ impl Body<'static> { | "hover" | "rename" | "bulk" - | "yank" + | "@yank" | "move" | "trash" | "delete" @@ -63,7 +63,11 @@ impl Body<'static> { bail!("Cannot construct system event"); } - if !kind.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-') { + let mut it = kind.bytes().peekable(); + if it.peek() == Some(&b'@') { + it.next(); // Skip `@` as it's a prefix for static messages + } + if !it.all(|b| b.is_ascii_alphanumeric() || b == b'-') { bail!("Kind must be alphanumeric with dashes"); } @@ -82,7 +86,7 @@ impl<'a> Body<'a> { Self::Hover(_) => "hover", Self::Rename(_) => "rename", Self::Bulk(_) => "bulk", - Self::Yank(_) => "yank", + Self::Yank(_) => "@yank", Self::Move(_) => "move", Self::Trash(_) => "trash", Self::Delete(_) => "delete", diff --git a/yazi-dds/src/pubsub.rs b/yazi-dds/src/pubsub.rs index 225780f4..c016889c 100644 --- a/yazi-dds/src/pubsub.rs +++ b/yazi-dds/src/pubsub.rs @@ -137,13 +137,13 @@ impl Pubsub { } pub fn pub_from_yank(cut: bool, urls: &HashSet) { - if LOCAL.read().contains_key("yank") { + if LOCAL.read().contains_key("@yank") { Self::pub_(BodyYank::dummy()); } - if Self::own_static_ability("yank") { + if Self::own_static_ability("@yank") { Client::push(BodyYank::borrowed(cut, urls)); } - if BOOT.local_events.contains("yank") { + if BOOT.local_events.contains("@yank") { BodyYank::borrowed(cut, urls).with_receiver(*ID).flush(); } } diff --git a/yazi-dds/src/server.rs b/yazi-dds/src/server.rs index d7225172..8085fe51 100644 --- a/yazi-dds/src/server.rs +++ b/yazi-dds/src/server.rs @@ -66,7 +66,7 @@ impl Server { continue; } - if receiver == 0 { + if receiver == 0 && kind.starts_with('@') { let Some(body) = parts.next() else { continue }; if !STATE.set(kind, sender, body) { continue } } diff --git a/yazi-plugin/preset/plugins/session.lua b/yazi-plugin/preset/plugins/session.lua index 6a5fcfdf..c20d94b6 100644 --- a/yazi-plugin/preset/plugins/session.lua +++ b/yazi-plugin/preset/plugins/session.lua @@ -1,6 +1,6 @@ local function setup(_, opts) if opts.sync_yanked then - ps.sub_remote("yank", function(body) ya.manager_emit("update_yanked", { cut = body.cut, urls = body }) end) + ps.sub_remote("@yank", function(body) ya.manager_emit("update_yanked", { cut = body.cut, urls = body }) end) end end