diff --git a/src/sql/base/query/browser/untitledQueryEditorInput.ts b/src/sql/base/query/browser/untitledQueryEditorInput.ts index 71264d6c40..1df6c062e0 100644 --- a/src/sql/base/query/browser/untitledQueryEditorInput.ts +++ b/src/sql/base/query/browser/untitledQueryEditorInput.ts @@ -34,6 +34,10 @@ export class UntitledQueryEditorInput extends QueryEditorInput implements IUntit @IInstantiationService instantiationService: IInstantiationService, ) { super(description, text, results, connectionManagementService, queryModelService, configurationService, instantiationService); + // Set the mode explicitely to stop the auto language detection service from changing the mode unexpectedly. + // the auto language detection service won't do the language change only if the mode is explicitely set. + // if the mode (e.g. kusto, sql) do not exist for whatever reason, we will default it to sql. + text.setMode(text.getMode() ?? 'sql'); } public override resolve(): Promise { diff --git a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts index 430bd38d6d..d75497afa8 100644 --- a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts +++ b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts @@ -59,10 +59,6 @@ export class QueryEditorService implements IQueryEditorService { // Create a sql document pane with accoutrements const mode = this._connectionManagementService.getProviderLanguageMode(connectionProviderName); const fileInput = this._editorService.createEditorInput({ forceUntitled: true, resource: docUri, mode: mode }) as UntitledTextEditorInput; - // Set the mode explicitely to stop the language detection service from changing the mode unexpectedly. - // The mode parameter used when creating the editorInput is used as preferred mode, - // the language detection service won't do the language change only if the mode is explicitely set. - fileInput.setMode(mode); let untitledEditorModel = await fileInput.resolve(); if (options.initalContent) { untitledEditorModel.textEditorModel.setValue(options.initalContent);