Skip to content

Commit 3e045a4

Browse files
committed
Ensure that the previously selected commit remains selected after refreshing. Fixes brotherbard#87, brotherbard#91, brotherbard#102, #124.
1 parent aae5e7c commit 3e045a4

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

PBGitHistoryController.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
PBGitTree *gitTree;
4949
PBGitCommit *webCommit;
5050
PBGitCommit *selectedCommit;
51-
PBGitCommit *selectedCommitBeforeRefresh;
5251
}
5352

5453
@property (unsafe_unretained) IBOutlet NSTreeController* treeController;

PBGitHistoryController.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,20 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
248248
}else if ([context isEqualToString:@"branchFilterChange"]) {
249249
[PBGitDefaults setBranchFilter:repository.currentBranchFilter];
250250
[self updateBranchFilterMatrix];
251-
}else if([context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) {
252-
[self updateStatus];
253-
254-
if (selectedCommitBeforeRefresh && [repository commitForSHA:[selectedCommitBeforeRefresh sha]])
255-
[self selectCommit:[selectedCommitBeforeRefresh sha]];
256-
else if ([repository.currentBranch isSimpleRef])
257-
[self selectCommit:[repository shaForRef:[repository.currentBranch ref]]];
258-
else
259-
[self selectCommit:[[self firstCommit] sha]];
260-
}else{
251+
}
252+
else if([context isEqualToString:@"updateCommitCount"] || [(NSString *)context isEqualToString:@"revisionListUpdating"]) {
253+
// Only refresh the selected commit when the revision list has finished graphing
254+
if (isBusy && !repository.revisionList.isUpdating) {
255+
if (selectedCommit && [repository commitForSHA:[selectedCommit sha]])
256+
[self selectCommit:[selectedCommit sha]];
257+
else if ([repository.currentBranch isSimpleRef])
258+
[self selectCommit:[repository shaForRef:[repository.currentBranch ref]]];
259+
else
260+
[self selectCommit:[[self firstCommit] sha]];
261+
}
262+
[self updateStatus];
263+
}
264+
else{
261265
[super observeValueForKeyPath:keyPath ofObject:object change:change context:ctx];
262266
}
263267

@@ -408,9 +412,7 @@ - (void) updateQuicklookForce:(BOOL)force
408412

409413
- (IBAction) refresh:(id)sender
410414
{
411-
selectedCommitBeforeRefresh = selectedCommit;
412415
[repository forceUpdateRevisions];
413-
selectedCommitBeforeRefresh = NULL;
414416
}
415417

416418
- (void) updateView

0 commit comments

Comments
 (0)