git: countBadge config

This commit is contained in:
Joao Moreno
2017-01-31 17:06:21 +01:00
parent adb32aa444
commit da1a21d1de
9 changed files with 47 additions and 10 deletions
+14 -1
View File
@@ -374,7 +374,10 @@
"title": "Git",
"properties": {
"git.path": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "%config.path%",
"default": null,
"isExecutable": true
@@ -393,6 +396,16 @@
"type": "boolean",
"description": "%config.enableLongCommitWarning%",
"default": true
},
"git.countBadge": {
"type": "string",
"enum": [
"all",
"tracked",
"off"
],
"description": "%config.countBadge%",
"default": "all"
}
}
}
+2 -1
View File
@@ -26,5 +26,6 @@
"config.path": "Path to the git executable",
"config.autorefresh": "Whether auto refreshing is enabled",
"config.autofetch": "Whether auto fetching is enabled",
"config.enableLongCommitWarning": "Whether long commit messages should be warned about"
"config.enableLongCommitWarning": "Whether long commit messages should be warned about",
"config.countBadge": "Controls the git badge counter"
}
+11 -1
View File
@@ -5,7 +5,7 @@
'use strict';
import { scm, Uri, Disposable, SCMProvider, SCMResourceGroup, Event, ProviderResult } from 'vscode';
import { scm, Uri, Disposable, SCMProvider, SCMResourceGroup, Event, ProviderResult, workspace } from 'vscode';
import { Model, Resource, ResourceGroup } from './model';
import { CommandCenter } from './commands';
@@ -17,6 +17,16 @@ export class GitSCMProvider implements SCMProvider {
get onDidChange(): Event<SCMResourceGroup[]> { return this.model.onDidChange; }
get label(): string { return 'Git'; }
get count(): number {
const countBadge = workspace.getConfiguration('git').get<string>('countBadge');
switch (countBadge) {
case 'off': return 0;
case 'tracked': return this.model.indexGroup.resources.length;
default: return this.model.resources.reduce((r, g) => r + g.resources.length, 0);
}
}
constructor(private model: Model, private commandCenter: CommandCenter) {
scm.registerSCMProvider('git', this);
}