From 367dc9b82cdea7ffdb90afbdc1d88a4e89c94db0 Mon Sep 17 00:00:00 2001 From: MiMoHo Date: Sat, 11 Jul 2026 18:00:30 +0200 Subject: [PATCH] Guard pasteFromStack against double-fire (modifier release + Return) Releasing the bezel hotkey modifiers pastes the selected clipping. If the user also presses Return right after (muscle memory from sticky-bezel mode, or simply confirming the selection), processBezelKeyDown triggers a second pasteFromStack before the bezel hides, pasting the clipping twice. Ignore a second trigger within 0.6s - the window in which hideApp (0.2s) and fakeCommandV (0.5s) from the first trigger are still pending. Co-Authored-By: Claude Fable 5 --- AppController.h | 1 + AppController.m | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/AppController.h b/AppController.h index 669bed8..38a54a2 100755 --- a/AppController.h +++ b/AppController.h @@ -35,6 +35,7 @@ SRKeyCodeTransformer *srTransformer; BOOL isBezelDisplayed; BOOL isBezelPinned; + NSTimeInterval lastPasteFromStackTime; NSString *currentKeycodeCharacter; NSDateFormatter* dateFormat; diff --git a/AppController.m b/AppController.m index 3898ab0..c69e45b 100755 --- a/AppController.m +++ b/AppController.m @@ -883,6 +883,14 @@ - (void)restoreStashedStoreAndUpdate - (void)pasteFromStack { NSLog(@"pasteFromStack called"); + // Releasing the modifier keys and pressing Return within a fraction of a second + // both trigger a paste, so the same bezel selection would be pasted twice. + NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; + if ( now - lastPasteFromStackTime < 0.6 ) { + NSLog(@"pasteFromStack ignored - duplicate trigger within 0.6s"); + return; + } + lastPasteFromStackTime = now; NSString *content = [flycutOperator getPasteFromStackPosition]; if ( nil != content ) { NSLog(@"Content found, adding to pasteboard and preparing to paste: %@", [content substringToIndex:MIN(content.length, 50)]);