mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
9ef7d27daa
commit
1bedbb7ca6
4 changed files with 13 additions and 9 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -137,13 +137,13 @@ impl Pubsub {
|
|||
}
|
||||
|
||||
pub fn pub_from_yank(cut: bool, urls: &HashSet<Url>) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue