提交 5efffdfc 编写于 作者: J Johannes Rieken

add git.decorations.enabled setting, #37299

上级 155fbe80
......@@ -829,6 +829,11 @@
"type": "boolean",
"description": "%config.enableCommitSigning%",
"default": false
},
"git.decorations.enabled": {
"type": "boolean",
"default": true,
"description": "%config.decorations.enabled%"
}
}
},
......
......@@ -57,6 +57,7 @@
"config.enableSmartCommit": "Commit all changes when there are no staged changes.",
"config.enableCommitSigning": "Enables commit signing with GPG.",
"config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.",
"config.decorations.enabled": "Controls if Git contributes colors and badges to the explorer and the open editors view.",
"colors.modified": "Color for modified resources.",
"colors.deleted": "Color for deleted resources.",
"colors.untracked": "Color for untracked resources.",
......
......@@ -118,15 +118,35 @@ class GitDecorationProvider implements DecorationProvider {
export class GitDecorations {
private disposables: Disposable[] = [];
private configListener: Disposable;
private modelListener: Disposable[] = [];
private providers = new Map<Repository, Disposable>();
constructor(private model: Model) {
this.disposables.push(
model.onDidOpenRepository(this.onDidOpenRepository, this),
model.onDidCloseRepository(this.onDidCloseRepository, this)
);
model.repositories.forEach(this.onDidOpenRepository, this);
this.configListener = workspace.onDidChangeConfiguration(e => e.affectsConfiguration('git.decorations.enabled') && this.update());
this.update();
}
private update(): void {
const enabled = workspace.getConfiguration('git').get('decorations.enabled');
if (enabled) {
this.enable();
} else {
this.disable();
}
}
private enable(): void {
this.modelListener = [];
this.model.onDidOpenRepository(this.onDidOpenRepository, this, this.modelListener);
this.model.onDidCloseRepository(this.onDidCloseRepository, this, this.modelListener);
this.model.repositories.forEach(this.onDidOpenRepository, this);
}
private disable(): void {
this.modelListener.forEach(d => d.dispose());
this.providers.forEach(value => value.dispose());
this.providers.clear();
}
private onDidOpenRepository(repository: Repository): void {
......@@ -144,7 +164,8 @@ export class GitDecorations {
}
dispose(): void {
this.disposables.forEach(d => d.dispose());
this.configListener.dispose();
this.modelListener.forEach(d => d.dispose());
this.providers.forEach(value => value.dispose);
this.providers.clear();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册