From 2bbe9c533005e97f163ed38e1cfe85ea23787aeb Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 13 Jan 2020 12:47:04 -0800 Subject: [PATCH] Only override editor opening for resource that have potential custom editors For #88525 --- .../contrib/customEditor/browser/customEditors.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts index 25ce3d2fc38..bc76a68485d 100644 --- a/src/vs/workbench/contrib/customEditor/browser/customEditors.ts +++ b/src/vs/workbench/contrib/customEditor/browser/customEditors.ts @@ -347,9 +347,15 @@ export class CustomEditorContribution implements IWorkbenchContribution { options: ITextEditorOptions | undefined, group: IEditorGroup ): IOpenEditorOverride | undefined { + const userConfiguredEditors = this.customEditorService.getUserConfiguredCustomEditors(resource); + const contributedEditors = this.customEditorService.getContributedCustomEditors(resource); + if (!userConfiguredEditors.length && !contributedEditors.length) { + return; + } + // Check to see if there already an editor for the resource in the group. // If there is, we want to open that instead of creating a new editor. - // This ensures that we preserve whatever state the editor was previously in + // This ensures that we preserve whatever type of editor was previously being used // when the user switches back to it. const existingEditorForResource = group.editors.find(editor => isEqual(resource, editor.getResource())); if (existingEditorForResource) { @@ -358,14 +364,12 @@ export class CustomEditorContribution implements IWorkbenchContribution { }; } - const userConfiguredEditors = this.customEditorService.getUserConfiguredCustomEditors(resource); if (userConfiguredEditors.length) { return { override: this.customEditorService.openWith(resource, userConfiguredEditors.allEditors[0].id, options, group), }; } - const contributedEditors = this.customEditorService.getContributedCustomEditors(resource); if (!contributedEditors.length) { return; }