Skip to content

Commit fd8d33b

Browse files
committed
Add a method to move down to the previous commit in branch
This wires "⌃↓" to do that
1 parent 8d20dad commit fd8d33b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Classes/Controllers/PBGitHistoryController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
6262
// Find/Search methods
6363
- (IBAction)selectNext:(id)sender;
6464
- (IBAction)selectPrevious:(id)sender;
65+
- (IBAction)selectParentCommit:(id)sender;
6566

6667
- (IBAction)copy:(id)sender;
6768
- (IBAction)copySHA:(id)sender;

Classes/Controllers/PBGitHistoryController.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,21 @@ - (IBAction)selectPrevious:(id)sender
448448
[searchController selectPreviousResult];
449449
}
450450

451+
- (IBAction) selectParentCommit:(id)sender
452+
{
453+
NSArray *selectedObjects = commitController.selectedObjects;
454+
if (selectedObjects.count != 1) return;
455+
456+
PBGitCommit *selectedCommit = selectedObjects[0];
457+
458+
NSArray <GTOID *> *parents = selectedCommit.parents;
459+
/* TODO: This is a merge commit. It would be nice to choose the parent with
460+
* the most commits, but for now we will use whatever commit is our first parent.
461+
*/
462+
463+
[self selectCommit:parents[0]];
464+
}
465+
451466
- (IBAction) copy:(id)sender
452467
{
453468
[GitXCommitCopier putStringToPasteboard:[GitXCommitCopier toSHAAndHeadingString:commitController.selectedObjects]];

Classes/PBCommitList.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ - (void)keyDown:(NSEvent *)event
4343
}
4444
else if ([character rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"jkcv"]].location == 0)
4545
[webController sendKey: character];
46-
else
46+
else if (([character characterAtIndex:0] == NSDownArrowFunctionKey)
47+
&& [event modifierFlags] & NSControlKeyMask) {
48+
[controller selectParentCommit:self];
49+
} else
4750
[super keyDown: event];
4851
}
4952

0 commit comments

Comments
 (0)