Skip to content

Commit

Permalink
set git.mergeChanges context key for all repos, not just one (#162339)
Browse files Browse the repository at this point in the history
fixes #162224
  • Loading branch information
jrieken committed Sep 29, 2022
1 parent 187f099 commit a2fe848
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 16 additions & 1 deletion extensions/git/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,21 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
.forEach(p => this.eventuallyScanPossibleGitRepository(p));
};

const statusListener = repository.onDidRunGitStatus(checkForSubmodules);
const updateMergeChanges = () => {
// set mergeChanges context
const mergeChanges: Uri[] = [];
for (const { repository } of this.openRepositories.values()) {
for (const state of repository.mergeGroup.resourceStates) {
mergeChanges.push(state.resourceUri);
}
}
commands.executeCommand('setContext', 'git.mergeChanges', mergeChanges);
};

const statusListener = repository.onDidRunGitStatus(() => {
checkForSubmodules();
updateMergeChanges();
});
checkForSubmodules();

const dispose = () => {
Expand All @@ -466,6 +480,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand

const openRepository = { repository, dispose };
this.openRepositories.push(openRepository);
updateMergeChanges();
this._onDidOpenRepository.fire(repository);
}

Expand Down
3 changes: 0 additions & 3 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2103,9 +2103,6 @@ export class Repository implements Disposable {
// set count badge
this.setCountBadge();

// set mergeChanges context
commands.executeCommand('setContext', 'git.mergeChanges', merge.map(item => item.resourceUri));

this._onDidChangeStatus.fire();

this._sourceControl.commitTemplate = await this.getInputTemplate();
Expand Down

0 comments on commit a2fe848

Please sign in to comment.