提交 15965f44 编写于 作者: J Joao Moreno

cleanup 'scm.enableDiffDecorations' setting

上级 edd5aba8
......@@ -1000,30 +1000,59 @@ class DirtyDiffItem {
export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution, IModelRegistry {
private enabled = false;
private models: IModel[] = [];
private items: { [modelId: string]: DirtyDiffItem; } = Object.create(null);
private transientDisposables: IDisposable[] = [];
private disposables: IDisposable[] = [];
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IInstantiationService private instantiationService: IInstantiationService,
@IConfigurationService private configurationService: IConfigurationService
) {
this.disposables.push(editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
const onDidChangeEnablement = filterEvent(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.enableDiffDecorations'));
onDidChangeEnablement(this.onDidChangeEnablement, this, this.disposables);
this.onDidChangeEnablement();
}
private onEditorsChanged(): void {
// HACK: This is the best current way of figuring out whether to draw these decorations
// or not. Needs context from the editor, to know whether it is a diff editor, in place editor
// etc.
private onDidChangeEnablement(): void {
const enabled = this.configurationService.getValue('scm.enableDiffDecorations');
if (enabled) {
this.enable();
} else {
this.disable();
}
}
private enable(): void {
if (this.enabled) {
return;
}
const enableDecorators = this.configurationService.getValue('editor.enableDecorators');
this.transientDisposables.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.onEditorsChanged();
this.enabled = true;
}
if (!enableDecorators) {
private disable(): void {
if (!this.enabled) {
return;
}
this.transientDisposables = dispose(this.transientDisposables);
this.models.forEach(m => this.items[m.id].dispose());
this.models = [];
this.items = Object.create(null);
this.enabled = false;
}
// HACK: This is the best current way of figuring out whether to draw these decorations
// or not. Needs context from the editor, to know whether it is a diff editor, in place editor
// etc.
private onEditorsChanged(): void {
const models = this.editorService.getVisibleEditors()
// map to the editor controls
......@@ -1075,11 +1104,8 @@ export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution,
}
dispose(): void {
this.disable();
this.disposables = dispose(this.disposables);
this.models.forEach(m => this.items[m.id].dispose());
this.models = null;
this.items = null;
}
}
......
......@@ -64,14 +64,14 @@ Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions
);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
id: 'editor',
id: 'scm',
order: 5,
type: 'object',
properties: {
'editor.enableDecorators': {
'scm.enableDiffDecorations': {
'type': 'boolean',
'default': true,
'description': localize('enableDecorators', "Enables or disables color decorators when changes happen in the editor.")
'description': localize('enableDiffDecorations', "Enables or disables diff decorations in the editor.")
},
}
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册