@@ -48,7 +48,6 @@ - (void)awakeFromNib
48
48
[treeController addObserver: self forKeyPath: @" selection" options: 0 context: @" treeChange" ];
49
49
50
50
[repository.revisionList addObserver: self forKeyPath: @" isUpdating" options: 0 context: @" revisionListUpdating" ];
51
- [repository.revisionList addObserver: self forKeyPath: @" updatedGraph" options: 0 context: @" revisionListUpdatedGraph" ];
52
51
[repository addObserver: self forKeyPath: @" currentBranch" options: 0 context: @" branchChange" ];
53
52
[repository addObserver: self forKeyPath: @" refs" options: 0 context: @" updateRefs" ];
54
53
@@ -83,26 +82,34 @@ - (void)awakeFromNib
83
82
[super awakeFromNib ];
84
83
}
85
84
86
- - (void ) updateKeys
85
+ - (void )updateKeys
87
86
{
88
- // Remove any references in the QLPanel
89
- // [[QLPreviewPanel sharedPreviewPanel] setURLs:[NSArray array] currentIndex:0 preservingDisplayState:YES];
90
- // We have to do this manually, as NSTreeController leaks memory?
91
- // [treeController setSelectionIndexPaths:[NSArray array]] ;
87
+ PBGitCommit *lastObject = [[commitController selectedObjects ] lastObject ];
88
+ if (lastObject) {
89
+ if (![selectedCommit isEqual: lastObject]) {
90
+ selectedCommit = lastObject ;
92
91
93
- selectedCommit = [[commitController selectedObjects ] lastObject ];
92
+ BOOL isOnHeadBranch = [selectedCommit isOnHeadBranch ];
93
+ [mergeButton setEnabled: !isOnHeadBranch];
94
+ [cherryPickButton setEnabled: !isOnHeadBranch];
95
+ [rebaseButton setEnabled: !isOnHeadBranch];
96
+ }
97
+ }
98
+ else {
99
+ [mergeButton setEnabled: NO ];
100
+ [cherryPickButton setEnabled: NO ];
101
+ [rebaseButton setEnabled: NO ];
102
+ }
94
103
95
104
if (self.selectedCommitDetailsIndex == kHistoryTreeViewIndex ) {
96
105
self.gitTree = selectedCommit.tree ;
97
106
[self restoreFileBrowserSelection ];
98
107
}
99
- else // kHistoryDetailViewIndex
108
+ else {
109
+ // kHistoryDetailViewIndex
110
+ if (![self .webCommit isEqual: selectedCommit])
100
111
self.webCommit = selectedCommit;
101
-
102
- BOOL isOnHeadBranch = [selectedCommit isOnHeadBranch ];
103
- [mergeButton setEnabled: !isOnHeadBranch];
104
- [cherryPickButton setEnabled: !isOnHeadBranch];
105
- [rebaseButton setEnabled: !isOnHeadBranch];
112
+ }
106
113
}
107
114
108
115
- (void ) updateBranchFilterMatrix
@@ -141,6 +148,11 @@ - (PBGitCommit *) firstCommit
141
148
return nil ;
142
149
}
143
150
151
+ - (BOOL )isCommitSelected
152
+ {
153
+ return [selectedCommit isEqual: [[commitController selectedObjects ] lastObject ]];
154
+ }
155
+
144
156
- (void ) setSelectedCommitDetailsIndex : (int )detailsIndex
145
157
{
146
158
if (selectedCommitDetailsIndex == detailsIndex)
@@ -230,10 +242,7 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
230
242
231
243
if ([(NSString *)context isEqualToString: @" updateCommitCount" ] || [(NSString *)context isEqualToString: @" revisionListUpdating" ]) {
232
244
[self updateStatus ];
233
- return ;
234
- }
235
245
236
- if ([(NSString *)context isEqualToString: @" revisionListUpdatedGraph" ]) {
237
246
if ([repository.currentBranch isSimpleRef ])
238
247
[self selectCommit: [repository shaForRef: [repository.currentBranch ref ]]];
239
248
else
@@ -399,7 +408,7 @@ - (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA
399
408
400
409
- (void )selectCommit : (PBGitSHA *)commitSHA
401
410
{
402
- if (!forceSelectionUpdate && [[selectedCommit sha ] isEqual: commitSHA])
411
+ if (!forceSelectionUpdate && [[[[commitController selectedObjects ] lastObject ] sha ] isEqual: commitSHA])
403
412
return ;
404
413
405
414
NSInteger oldIndex = [[commitController selectionIndexes ] firstIndex ];
@@ -409,6 +418,8 @@ - (void)selectCommit:(PBGitSHA *)commitSHA
409
418
410
419
if (repository.currentBranchFilter != kGitXSelectedBranchFilter )
411
420
[self scrollSelectionToTopOfViewFrom: oldIndex];
421
+
422
+ forceSelectionUpdate = NO ;
412
423
}
413
424
414
425
- (BOOL ) hasNonlinearPath
@@ -428,7 +439,6 @@ - (void)closeView
428
439
[treeController removeObserver: self forKeyPath: @" selection" ];
429
440
430
441
[repository.revisionList removeObserver: self forKeyPath: @" isUpdating" ];
431
- [repository.revisionList removeObserver: self forKeyPath: @" updatedGraph" ];
432
442
[repository removeObserver: self forKeyPath: @" currentBranch" ];
433
443
[repository removeObserver: self forKeyPath: @" refs" ];
434
444
}
0 commit comments