mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
git: countBadge config
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user