From bf5f18ea7225aa2c0598b9d58004d090dc1e0524 Mon Sep 17 00:00:00 2001 From: Maddy <12754347+MaddyDev@users.noreply.github.com> Date: Mon, 24 Jan 2022 14:17:34 -0800 Subject: [PATCH] set mode explicitly to notebook (#18089) * set mode explicitly to notebook * move setMode to untitledNotebookInput * wait until input is resolved for setMode * invoke only when textInput is undefined * pass the untitledTextInput in test --- .../contrib/notebook/browser/models/untitledNotebookInput.ts | 2 ++ .../contrib/notebook/test/browser/notebookInput.test.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sql/workbench/contrib/notebook/browser/models/untitledNotebookInput.ts b/src/sql/workbench/contrib/notebook/browser/models/untitledNotebookInput.ts index a518424e4b..8b7b522dd7 100644 --- a/src/sql/workbench/contrib/notebook/browser/models/untitledNotebookInput.ts +++ b/src/sql/workbench/contrib/notebook/browser/models/untitledNotebookInput.ts @@ -26,6 +26,8 @@ export class UntitledNotebookInput extends NotebookInput { @IExtensionService extensionService: IExtensionService ) { super(title, resource, textInput, true, textModelService, instantiationService, notebookService, extensionService); + // Set the mode explicitly so that the auto language detection doesn't run and mark the model as being JSON + this.textInput.resolve().then(() => this.setMode('notebook')); } public override get textInput(): UntitledTextEditorInput { diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookInput.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookInput.test.ts index 5f5ad24ea6..7a6c2bd169 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookInput.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookInput.test.ts @@ -84,7 +84,7 @@ suite('Notebook Input', function (): void { // Input title assert.strictEqual(untitledNotebookInput.getTitle(), testTitle); - let noTitleInput = instantiationService.createInstance(UntitledNotebookInput, undefined, untitledUri, undefined); + let noTitleInput = instantiationService.createInstance(UntitledNotebookInput, undefined, untitledUri, untitledTextInput); assert.strictEqual(noTitleInput.getTitle(), basenameOrAuthority(untitledUri)); // Text Input