Skip to content

Commit 5e2614b

Browse files
authored
sessions - fix wrong use of ahead/behind in sync action (#298254)
fix - update sync action registration logic
1 parent 8f0ea5c commit 5e2614b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/vs/sessions/contrib/gitSync/browser/gitSync.contribution.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ class GitSyncContribution extends Disposable implements IWorkbenchContribution {
4848
return;
4949
}
5050

51+
const repoDisposables = this._gitRepoDisposables.add(new DisposableStore());
5152
this.gitService.openRepository(worktreeUri).then(repository => {
53+
if (repoDisposables.isDisposed) {
54+
return;
55+
}
5256
if (!repository) {
5357
this._syncActionDisposable.clear();
5458
contextKey.set(false);
5559
return;
5660
}
57-
this._gitRepoDisposables.add(autorun(innerReader => {
61+
repoDisposables.add(autorun(innerReader => {
5862
const state = repository.state.read(innerReader);
5963
const head = state.HEAD;
6064
if (!head?.upstream) {
@@ -66,7 +70,7 @@ class GitSyncContribution extends Disposable implements IWorkbenchContribution {
6670
const behind = head.behind ?? 0;
6771
const hasSyncChanges = ahead > 0 || behind > 0;
6872
contextKey.set(hasSyncChanges);
69-
this._syncActionDisposable.value = registerSyncAction(ahead, behind);
73+
this._syncActionDisposable.value = registerSyncAction(behind, ahead);
7074
}));
7175
});
7276
}));

0 commit comments

Comments
 (0)