Skip to content

Commit 6f5d027

Browse files
authored
Merge pull request laullon#21 from tiennou/feature/commit-list-select-parent
Add a method to move down to the previous commit in branch
2 parents f579c20 + fd8d33b commit 6f5d027

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
@@ -60,6 +60,7 @@ NS_ASSUME_NONNULL_BEGIN
6060
// Find/Search methods
6161
- (IBAction)selectNext:(id)sender;
6262
- (IBAction)selectPrevious:(id)sender;
63+
- (IBAction)selectParentCommit:(id)sender;
6364

6465
- (IBAction)copy:(id)sender;
6566
- (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)