Skip to content

Commit

Permalink
Ensure that the previously selected commit remains selected after ref…
Browse files Browse the repository at this point in the history
…reshing. Fixes brotherbard#87, brotherbard#91, brotherbard#102, #124.
  • Loading branch information
jphalip committed Jun 6, 2012
1 parent aae5e7c commit 3e045a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion PBGitHistoryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
PBGitTree *gitTree;
PBGitCommit *webCommit;
PBGitCommit *selectedCommit;
PBGitCommit *selectedCommitBeforeRefresh;
}

@property (unsafe_unretained) IBOutlet NSTreeController* treeController;
Expand Down
26 changes: 14 additions & 12 deletions PBGitHistoryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,20 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
}else if ([context isEqualToString:@"branchFilterChange"]) {
[PBGitDefaults setBranchFilter:repository.currentBranchFilter];
[self updateBranchFilterMatrix];
}else if([context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) {
[self updateStatus];

if (selectedCommitBeforeRefresh && [repository commitForSHA:[selectedCommitBeforeRefresh sha]])
[self selectCommit:[selectedCommitBeforeRefresh sha]];
else if ([repository.currentBranch isSimpleRef])
[self selectCommit:[repository shaForRef:[repository.currentBranch ref]]];
else
[self selectCommit:[[self firstCommit] sha]];
}else{
}
else if([context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) {
// Only refresh the selected commit when the revision list has finished graphing
if (isBusy && !repository.revisionList.isUpdating) {
if (selectedCommit && [repository commitForSHA:[selectedCommit sha]])
[self selectCommit:[selectedCommit sha]];
else if ([repository.currentBranch isSimpleRef])
[self selectCommit:[repository shaForRef:[repository.currentBranch ref]]];
else
[self selectCommit:[[self firstCommit] sha]];
}
[self updateStatus];
}
else{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:ctx];
}

Expand Down Expand Up @@ -408,9 +412,7 @@ - (void) updateQuicklookForce:(BOOL)force

- (IBAction) refresh:(id)sender
{
selectedCommitBeforeRefresh = selectedCommit;
[repository forceUpdateRevisions];
selectedCommitBeforeRefresh = NULL;
}

- (void) updateView
Expand Down

0 comments on commit 3e045a4

Please sign in to comment.