From 9907db373c9f75ffcc66d652c604220b799da70c Mon Sep 17 00:00:00 2001 From: TZGyn Date: Tue, 27 Oct 2026 21:31:30 +0800 Subject: [PATCH] Add Copy & Delete to the context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copies the item (or the selection, as plain lines) and removes it in one step — the 'take this out' gesture. No shortcut: Cmd+X belongs to the text fields, and a panel binding would steal it. --- AGENTS.md | 2 +- Sources/Prompt/PanelView.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 718245d..aede21c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -60,7 +60,7 @@ clicking an item copies it back to the clipboard. switches sections. Click = select (Shift+click for a range); the selection bar offers Copy (single item), Copy as List, Copy as Lines and Delete; right-click = context menu acting on the whole selection (Copy, Copy as List, - Copy as Lines, Done, Edit, Open, Merge, Move To, Delete). Esc clears the + Copy as Lines, Copy & Delete, Done, Edit, Open, Merge, Move To, Delete). Esc clears the selection before it hides the panel. Selection is scoped to the current view: switching workspace, switching tab, or closing search clears it. Drop target for images/files. - `Sources/Prompt/PanelController.swift` — owns the floating `NSPanel` diff --git a/Sources/Prompt/PanelView.swift b/Sources/Prompt/PanelView.swift index 06d370d..04aed89 100644 --- a/Sources/Prompt/PanelView.swift +++ b/Sources/Prompt/PanelView.swift @@ -324,6 +324,9 @@ struct PanelView: View { store.copyAsLines(ids: ids) flashCopied(item.id) } + Button(multiple ? "Copy & Delete \(ids.count) Items" : "Copy & Delete") { + copyAndDelete(item) + } Divider() Button(item.done ? "Mark as Not Done" : "Mark as Done") { store.setDone(!item.done, ids: ids) @@ -855,6 +858,22 @@ struct PanelView: View { flashCopied(item.id) } + /// One gesture for "take this out": copy, then delete. A multi-selection + /// is copied as plain lines, same as Copy as Lines. No shortcut — Cmd+X + /// belongs to the composer/editor text fields, and a panel binding would + /// steal Cut from them. + private func copyAndDelete(_ item: PromptItem) { + let ids = effectiveIDs(for: item) + if ids.count > 1 { + store.copyAsLines(ids: ids) + } else { + store.copy(item) + } + store.delete(ids: ids) + selection.subtract(ids) + lastSelectedID = nil + } + private func flashCopied(_ id: UUID) { withAnimation { copiedID = id } DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {