Skip to content

Commit 03efcec

Browse files
authored
Merge pull request laullon#191 from claybridges/claybridges-no-scroll
Suppress rescroll when repo is updated externally
2 parents 532e03c + a19ee17 commit 03efcec

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Classes/Controllers/PBGitHistoryController.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,11 @@ - (void) _repositoryUpdatedNotification:(NSNotification *)notification {
180180
- (void)reselectCommitAfterUpdate {
181181
[self updateStatus];
182182

183-
if ([self.repository.currentBranch isSimpleRef])
184-
[self selectCommit:[self.repository OIDForRef:self.repository.currentBranch.ref]];
185-
else
186-
[self selectCommit:self.firstCommit.OID];
183+
if ([self.repository.currentBranch isSimpleRef]) {
184+
[self selectCommit:[self.repository OIDForRef:self.repository.currentBranch.ref] withRescroll:NO];
185+
} else {
186+
[self selectCommit:self.firstCommit.OID withRescroll:NO];
187+
}
187188
}
188189

189190
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row {
@@ -551,6 +552,11 @@ - (NSArray *) selectedObjectsForOID:(GTOID *)commitOID
551552
}
552553

553554
- (void)selectCommit:(GTOID *)commitOID
555+
{
556+
[self selectCommit:commitOID withRescroll:YES];
557+
}
558+
559+
- (void)selectCommit:(GTOID *)commitOID withRescroll:(BOOL)doRescroll
554560
{
555561
if (!forceSelectionUpdate && [[[commitController.selectedObjects lastObject] OID] isEqual:commitOID]) {
556562
return;
@@ -559,8 +565,10 @@ - (void)selectCommit:(GTOID *)commitOID
559565
NSArray *selectedObjects = [self selectedObjectsForOID:commitOID];
560566
[commitController setSelectedObjects:selectedObjects];
561567

562-
NSInteger oldIndex = [[commitController selectionIndexes] firstIndex];
563-
[self scrollSelectionToTopOfViewFrom:oldIndex];
568+
if (doRescroll) {
569+
NSInteger oldIndex = [[commitController selectionIndexes] firstIndex];
570+
[self scrollSelectionToTopOfViewFrom:oldIndex];
571+
}
564572

565573
forceSelectionUpdate = NO;
566574
}

0 commit comments

Comments
 (0)