mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Multiple changes to -selectCommit: from PBGitHistoryController.
- Change return type from void to BOOL to convey if selecting succeeded or not. - Return NO if the cliArgs from sharedApplicationController contain "--commit", since then we need to just show the commit stage. Updating the commit list selection is not necessary. In fact, it will confuse order among consequent calls. - If the oldIndex equals NSNotFound, try to get the index of the currently selected object by finding it among the content object of the commitController. If we find it we save the result in an ivar called selectedCommit so that subsequent calls will always have this available as an alternative back-up plan.
This commit is contained in:
@@ -71,11 +71,12 @@
|
||||
- (IBAction) setDetailedView:(id)sender;
|
||||
- (IBAction) setTreeView:(id)sender;
|
||||
- (IBAction) setBranchFilter:(id)sender;
|
||||
|
||||
- (void) selectCommit: (NSString*) commit;
|
||||
- (IBAction) refresh:(id)sender;
|
||||
- (IBAction) toggleQLPreviewPanel:(id)sender;
|
||||
- (IBAction) openSelectedFile:(id)sender;
|
||||
|
||||
- (BOOL) selectCommit: (NSString*) commit;
|
||||
|
||||
- (void) updateQuicklookForce: (BOOL) force;
|
||||
|
||||
|
||||
|
||||
@@ -424,18 +424,32 @@
|
||||
return selectedCommits;
|
||||
}
|
||||
|
||||
- (void) selectCommit:(NSString *)commitSHA
|
||||
- (BOOL) selectCommit:(NSString *)commitSHA
|
||||
{
|
||||
ApplicationController * appController = [ApplicationController sharedApplicationController];
|
||||
if (appController.launchedFromGitx && [appController.cliArgs isEqualToString:@"--commit"]) {
|
||||
return NO;
|
||||
}
|
||||
NSLog(@"[%@ %s]: SHA = %@", [self class], _cmd, commitSHA);
|
||||
if (!forceSelectionUpdate && [[selectedCommit realSha] isEqualToString:commitSHA])
|
||||
return;
|
||||
return NO;
|
||||
|
||||
NSInteger oldIndex = [[commitController selectionIndexes] firstIndex];
|
||||
if (oldIndex == NSNotFound) {
|
||||
oldIndex = [[commitController content] indexOfObject:selectedCommit];
|
||||
}
|
||||
|
||||
NSArray *selectedCommits = [self selectedObjectsForSHA:commitSHA];
|
||||
selectedCommit = [selectedCommits objectAtIndex:0];
|
||||
|
||||
[commitController setSelectedObjects:selectedCommits];
|
||||
|
||||
if (repository.currentBranchFilter != kGitXSelectedBranchFilter)
|
||||
[self scrollSelectionToTopOfViewFrom:oldIndex];
|
||||
if (repository.currentBranchFilter != kGitXSelectedBranchFilter) {
|
||||
NSLog(@"[%@ %s] currentBranchFilter = %@", [self class], _cmd, PBStringFromBranchFilterType(repository.currentBranchFilter));
|
||||
[self scrollSelectionToTopOfViewFrom:oldIndex];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) hasNonlinearPath
|
||||
|
||||
Reference in New Issue
Block a user