Skip to content

Commit 6e92c1a

Browse files
committed
Fix sidebar-refresh to respond to manual refreshes and external branch changes
The sidebar's checked-out branch checkmark does not update after a branch change made outside GitX (e.g. `git switch` in a terminal), or even after clicking GitX's own manual Refresh button, even though the commit-list header already updates correctly in both cases. reloadRefs already invalidates the cached HEAD ref and fires KVO on refs on every refresh cycle, automatic or manual, but PBGitSidebarController never observed that property. Observe refs in PBGitSidebarController and reload the outline view, preserving the current selection, so the checkmark badge is recomputed against the current HEAD whenever refs change, regardless of what triggered the refresh.
1 parent 8951252 commit 6e92c1a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎Classes/Controllers/PBGitSidebarController.m‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ - (void)awakeFromNib
113113
[observer.sourceView reloadItem:observer->stashes reloadChildren:YES];
114114
}];
115115

116+
[repository addObserver:self
117+
keyPath:@"refs"
118+
options:0
119+
block:^(MAKVONotification *notification) {
120+
PBGitSidebarController *observer = notification.observer;
121+
NSInteger row = observer.sourceView.selectedRow;
122+
[observer.sourceView reloadData];
123+
[observer.sourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
124+
}];
125+
116126
[sourceView setTarget:self];
117127
[sourceView setDoubleAction:@selector(doubleClicked:)];
118128

0 commit comments

Comments
 (0)