diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 85d0f4fdaee..373a8c23612 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -527,8 +527,6 @@ export class Repository implements Disposable { private readonly repository: BaseRepository, globalState: Memento ) { - const config = workspace.getConfiguration('git'); - const gitShowStagedChangesResourceGroup = config.get('showStagedChangesResourceGroup'); const fsWatcher = workspace.createFileSystemWatcher('**'); this.disposables.push(fsWatcher); @@ -551,8 +549,11 @@ export class Repository implements Disposable { this._indexGroup = this._sourceControl.createResourceGroup('index', localize('staged changes', "Staged Changes")); this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', localize('changes', "Changes")); + const onConfigListener = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.showStagedChangesResourceGroup')); + onConfigListener(this.showStagedChangesResourceGroup, this, this.disposables); + this.showStagedChangesResourceGroup(); + this.mergeGroup.hideWhenEmpty = true; - this.indexGroup.hideWhenEmpty = !gitShowStagedChangesResourceGroup; this.disposables.push(this.mergeGroup); this.disposables.push(this.indexGroup); @@ -651,6 +652,12 @@ export class Repository implements Disposable { } } + private showStagedChangesResourceGroup(): void { + const config = workspace.getConfiguration('git'); + const gitShowStagedChangesResourceGroup = config.get('showStagedChangesResourceGroup'); + this.indexGroup.hideWhenEmpty = !gitShowStagedChangesResourceGroup; + } + @throttle async status(): Promise { await this.run(Operation.Status);