From 0f73a4484744cb2e8cd6d7ada5c0b01c9570e7f1 Mon Sep 17 00:00:00 2001 From: Sinkerine Date: Tue, 24 Oct 2023 00:13:48 -0700 Subject: [PATCH] feat: Support unyank There are two options to put the unyank ability: - Option 1: Register a new command like in this CL - Option 2: Add the unyank to the escape sequence, maybe after the escape_select. I chose option 1 because the yank function is its own module but the escape sequence belongs to the tab class. Option 2 is infeasible without touching the module structure. I just randomly choose a meaninful and unoccuped key binding for the `unyank` function. Feel free to modify or remove it from the preset. I personally remap the yank related functions to dance keys such as ["y" "y"]. --- yazi-config/preset/keymap.toml | 1 + yazi-core/src/manager/commands/yank.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 52021f80..64e35c75 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -63,6 +63,7 @@ keymap = [ { on = [ "" ], exec = "open", desc = "Open the selected files" }, { on = [ "" ], exec = "open --interactive", desc = "Open the selected files interactively" }, { on = [ "y" ], exec = [ "yank", "escape --visual --select" ], desc = "Copy the selected files" }, + { on = [ "Y" ], exec = [ "unyank", "escape --visual --select" ], desc = "Remove the files from the yank clipboard" }, { on = [ "x" ], exec = [ "yank --cut", "escape --visual --select" ], desc = "Cut the selected files" }, { on = [ "p" ], exec = "paste", desc = "Paste the files" }, { on = [ "P" ], exec = "paste --force", desc = "Paste the files (overwrite if the destination exists)" }, diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/manager/commands/yank.rs index 7f1209a5..41605ed9 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/manager/commands/yank.rs @@ -18,4 +18,9 @@ impl Manager { self.yanked.1 = self.selected().into_iter().map(|f| f.url()).collect(); render!(); } + + pub fn unyank(&mut self) -> bool { + self.yanked = Default::default(); + true + } }