@@ -30,4 +30,45 @@ - (NSDragOperation) draggingSourceOperationMaskForLocal:(BOOL) local
3030 return NSDragOperationEvery;
3131}
3232
33+ #pragma mark NSView overrides
34+ - (void )keyDown : (NSEvent *)theEvent
35+ {
36+ PBGitIndexController* controller = (PBGitIndexController*)[self delegate ];
37+
38+ bool isUnstagedView = [self tag ] == 0 ;
39+ bool isStagedView = !isUnstagedView;
40+
41+ bool commandDown = theEvent.modifierFlags & NSCommandKeyMask ;
42+
43+ if ([theEvent.characters isEqualTo: @" s" ] && commandDown && isUnstagedView) {
44+ int oldSelectedRowIndex = self.selectedRow ;
45+ [controller stageSelectedFiles ];
46+
47+ // Try to select the file after the one that was just staged, which will have the same index now
48+ int rowIndexToSelect = oldSelectedRowIndex;
49+ if (rowIndexToSelect > self.numberOfRows - 1 ) {
50+ rowIndexToSelect = self.numberOfRows - 1 ;
51+ }
52+
53+
54+ [self selectRowIndexes: [NSIndexSet indexSetWithIndex: rowIndexToSelect] byExtendingSelection: NO ];
55+ }
56+ else if ([theEvent.characters isEqualTo: @" u" ] && commandDown && isStagedView) {
57+ int oldSelectedRowIndex = self.selectedRow ;
58+ [controller unstageSelectedFiles ];
59+
60+ // Try to select the file after the one that was just staged, which will have the same index now
61+ int rowIndexToSelect = oldSelectedRowIndex;
62+ if (rowIndexToSelect > self.numberOfRows - 1 ) {
63+ rowIndexToSelect = self.numberOfRows - 1 ;
64+ }
65+
66+ [self selectRowIndexes: [NSIndexSet indexSetWithIndex: rowIndexToSelect] byExtendingSelection: NO ];
67+
68+ }
69+ else {
70+ [super keyDown: theEvent];
71+ }
72+ }
73+
3374@end
0 commit comments