From 64076e6d66b8c385393ffb89bbc9d908ccc15041 Mon Sep 17 00:00:00 2001 From: wistcc Date: Tue, 7 Aug 2018 22:41:34 -0400 Subject: [PATCH 1/2] Adding the git.showStagedChangesResourceGroup config property --- extensions/git/package.json | 6 ++++++ extensions/git/package.nls.json | 1 + extensions/git/src/repository.ts | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index d4a9ebb0d58..ec158cd1287 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -987,6 +987,12 @@ "scope": "resource", "default": 10, "description": "%config.detectSubmodulesLimit%" + }, + "git.showStagedChangesResourceGroup": { + "type": "boolean", + "scope": "resource", + "default": false, + "description": "%config.showStagedChangesResourceGroup%" } } }, diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 9b1a2332d1f..41aad5b8788 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -72,6 +72,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.", "colors.modified": "Color for modified resources.", "colors.deleted": "Color for deleted resources.", "colors.untracked": "Color for untracked resources.", diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 5c5fd6814a3..eb89696244b 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -509,6 +509,8 @@ 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); @@ -532,7 +534,7 @@ export class Repository implements Disposable { this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', localize('changes', "Changes")); this.mergeGroup.hideWhenEmpty = true; - this.indexGroup.hideWhenEmpty = true; + this.indexGroup.hideWhenEmpty = !gitShowStagedChangesResourceGroup; this.disposables.push(this.mergeGroup); this.disposables.push(this.indexGroup); From 4e3f1e2a5edd2bd22e961dcc166040c1b5e5d302 Mon Sep 17 00:00:00 2001 From: wistcc Date: Wed, 8 Aug 2018 10:31:53 -0400 Subject: [PATCH 2/2] Addressing feedback --- extensions/git/src/repository.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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);