diff --git a/extensions/git/package.json b/extensions/git/package.json index befecc5ab71..fc31b690132 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -1034,11 +1034,11 @@ "default": 10, "description": "%config.detectSubmodulesLimit%" }, - "git.showStagedChangesResourceGroup": { + "git.alwaysShowStagedChangesResourceGroup": { "type": "boolean", "scope": "resource", "default": false, - "description": "%config.showStagedChangesResourceGroup%" + "description": "%config.alwaysShowStagedChangesResourceGroup%" }, "git.alwaysSignOff": { "type": "boolean", diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 7ee94d8c0d8..b3991f94b5c 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -85,7 +85,7 @@ "config.detectSubmodules": "Controls whether to automatically detect git submodules.", "colors.added": "Color for added resources.", "config.detectSubmodulesLimit": "Controls the limit of git submodules detected.", - "config.showStagedChangesResourceGroup": "Always show the Staged Changes resource group.", + "config.alwaysShowStagedChangesResourceGroup": "Always show the Staged Changes resource group.", "config.alwaysSignOff": "Controls the signoff flag for all commits.", "config.ignoredRepositories": "List of git repositories to ignore.", "config.showProgress": "Controls whether git actions should show progress.", diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index c2a5349ff2a..3e9134d5984 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -589,7 +589,8 @@ export class Repository implements Disposable { const onRelevantGitChange = filterEvent(onRelevantRepositoryChange, uri => /\/\.git\//.test(uri.path)); onRelevantGitChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, this.disposables); - this._sourceControl = scm.createSourceControl('git', 'Git', Uri.file(repository.root)); + const root = Uri.file(repository.root); + this._sourceControl = scm.createSourceControl('git', 'Git', root); this._sourceControl.inputBox.placeholder = localize('commitMessage', "Message (press {0} to commit)"); this._sourceControl.acceptInputCommand = { command: 'git.commitWithInput', title: localize('commit', "Commit"), arguments: [this._sourceControl] }; this._sourceControl.quickDiffProvider = this; @@ -600,9 +601,14 @@ 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(); + const updateIndexGroupVisibility = () => { + const config = workspace.getConfiguration('git', root); + this.indexGroup.hideWhenEmpty = !config.get('alwaysShowStagedChangesResourceGroup'); + }; + + const onConfigListener = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.alwaysShowStagedChangesResourceGroup', root)); + onConfigListener(updateIndexGroupVisibility, this, this.disposables); + updateIndexGroupVisibility(); this.mergeGroup.hideWhenEmpty = true; @@ -715,12 +721,6 @@ export class Repository implements Disposable { return this.run(Operation.Config, () => this.repository.config('local', key, value)); } - 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);