From 3856013466422a4da3c5c4515227b400e3a52792 Mon Sep 17 00:00:00 2001 From: MiMoHo Date: Thu, 30 Jul 2026 05:43:51 +0200 Subject: [PATCH] Save-and-delete in the favorites store deleted from the main list Shift+S in the bezel saves the selected clipping to a file and then removes it. With the favorites store active ('f' in the bezel) it removed the wrong clipping, from the wrong list: bool success = [flycutOperator saveFromStack]; // reads the favorites store [self performSelector:@selector(hideApp) ...]; [self restoreStashedStoreAndUpdate]; // swaps the store AND the position if ( success && shift ) [flycutOperator clearItemAtStackPosition]; -restoreStashedStore swaps clippingStore back to the main store and swaps stackPosition with stashedStackPosition, so the delete that follows hits the main list at whatever position the user had been at there before pressing 'f'. The favorite was saved and kept, and an unrelated clipping - one the user was never shown - was destroyed instead. Deleting before the restore fixes it: while the store that was saved from is still the current one, clearItemAtStackPosition removes exactly the clipping that was saved. Without an active stash -restoreStashedStore returns NO and the path is unchanged, so plain Shift+S in the main list behaves exactly as before. Verified with a test program driving the real FlycutOperator, modelling both orders (main list MAIN0..MAIN5 with the cursor at position 3, then 'f', favorites FAV0..FAV2 with the cursor at position 1, then Shift+S): before: main 6 -> 5, "MAIN2" gone, favorites unchanged (data loss) after: main unchanged at 6, favorites 3 -> 2, FAV1 gone (correct) Builds with Xcode 26.5, 76 warnings, identical to master. Co-Authored-By: Claude --- AppController.m | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/AppController.m b/AppController.m index 3898ab0..168f7f6 100755 --- a/AppController.m +++ b/AppController.m @@ -1187,16 +1187,21 @@ - (void)processBezelKeyDown:(NSEvent *)theEvent { case 's': case 'S': // Save / Save-and-delete { bool success = [flycutOperator saveFromStack]; - [self performSelector:@selector(hideApp) withObject:nil afterDelay:0.2]; - [self restoreStashedStoreAndUpdate]; - if ( success ) { - if ( modifiers & NSEventModifierFlagShift ) { - [flycutOperator clearItemAtStackPosition]; - [self updateBezel]; - [self updateMenu]; - } + // Delete while the store that was saved from is still the current one. + // -restoreStashedStore swaps the store AND the stack position back, so + // deleting after it removed an entry from the main list - at whatever + // position the user had been at there - instead of the clipping that had + // just been saved. Saving a favorite therefore destroyed an unrelated + // clipping. + if ( success && ( modifiers & NSEventModifierFlagShift ) ) { + [flycutOperator clearItemAtStackPosition]; + [self updateBezel]; + [self updateMenu]; } + + [self performSelector:@selector(hideApp) withObject:nil afterDelay:0.2]; + [self restoreStashedStoreAndUpdate]; } break; case 'f':