From 4145ecfb32b6a66c03b83beea677abec45860759 Mon Sep 17 00:00:00 2001 From: Anthony Dresser Date: Tue, 26 Nov 2019 14:28:27 -0800 Subject: [PATCH] default to using extension of the file for editor replacement (#8482) --- src/sql/workbench/common/editorReplacerContribution.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sql/workbench/common/editorReplacerContribution.ts b/src/sql/workbench/common/editorReplacerContribution.ts index 3d24444fd3..612c4c6666 100644 --- a/src/sql/workbench/common/editorReplacerContribution.ts +++ b/src/sql/workbench/common/editorReplacerContribution.ts @@ -14,6 +14,7 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Registry } from 'vs/platform/registry/common/platform'; +import * as path from 'vs/base/common/path'; import { ILanguageAssociationRegistry, Extensions as LanguageAssociationExtensions } from 'sql/workbench/common/languageAssociation'; @@ -55,6 +56,11 @@ export class EditorReplacementContribution implements IWorkbenchContribution { language = this.modeService.getModeIdByFilepathOrFirstLine(editor.getResource()); } + if (!language) { + // just use the extension + language = path.extname(editor.getResource().toString()).slice(1); // remove the . + } + if (!language) { const defaultInputCreator = languageAssociationRegistry.getAssociations().filter(e => e.isDefault)[0]; if (defaultInputCreator) {