Skip to content

Commit b4b8498

Browse files
committed
Change Amend Commit menu item to use an action instead of bindings.
Bindings can make the menu item behavior act erratically because the binding state is shared across the app, not per-document. This also adds a checkmark to the menu item when amending is active. Steps to reproduce a problem like this: - Open a repository - Select Amend Commit to start amending - Close the repository - Open the same repository - Select Amend Commit to start amending again - This time the menu item sets amend to NO instead of YES, so nothing happens the first time you select the menu item
1 parent 241e39c commit b4b8498

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Classes/Controllers/PBGitCommitController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ - (IBAction) forceCommit:(id) sender
253253
[self commitWithVerification:NO];
254254
}
255255

256+
- (IBAction)toggleAmendCommit:(id)sender
257+
{
258+
[[[self repository] index] setAmend:![[[self repository] index] isAmend]];
259+
}
260+
256261
- (NSArray <PBChangedFile *> *)selectedFilesForSender:(id)sender
257262
{
258263
NSParameterAssert(sender != nil);
@@ -692,6 +697,9 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
692697
}
693698
return active;
694699
}
700+
else if (menuItem.action == @selector(toggleAmendCommit:)) {
701+
menuItem.state = [[[self repository] index] isAmend] ? NSOnState : NSOffState;
702+
}
695703

696704
return menuItem.enabled;
697705
}

Resources/English.lproj/MainMenu.xib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ DQ
528528
<menuItem title="Amend Commit" keyEquivalent="a" id="W5p-JV-xeS">
529529
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
530530
<connections>
531-
<binding destination="oqX-ct-wMx" name="value" keyPath="currentDocument.windowController.repository.index.amend" id="qcF-1I-xfx"/>
531+
<action selector="toggleAmendCommit:" target="-1" id="sQs-hs-7cR"/>
532532
</connections>
533533
</menuItem>
534534
</items>

0 commit comments

Comments
 (0)