From 911c185dcd438651024ebcc7fcb52ff8ee844cba Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 26 Jan 2022 13:25:40 -0800 Subject: [PATCH] Fix untitled notebook save opening as JSON (#18156) --- .../contrib/notebook/browser/models/notebookInput.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts index 031a0532cb..bc80fc08b0 100644 --- a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts +++ b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts @@ -37,8 +37,12 @@ import { INotebookInput } from 'sql/workbench/services/notebook/browser/interfac import { EditorModel } from 'vs/workbench/common/editor/editorModel'; import { EditorInput } from 'vs/workbench/common/editor/editorInput'; import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager'; +import { Registry } from 'vs/platform/registry/common/platform'; +import { Extensions as LanguageAssociationExtensions, ILanguageAssociationRegistry } from 'sql/workbench/services/languageAssociation/common/languageAssociation'; +import { NotebookLanguage } from 'sql/workbench/common/constants'; export type ModeViewSaveHandler = (handle: number) => Thenable; +const languageAssociationRegistry = Registry.as(LanguageAssociationExtensions.LanguageAssociations); export class NotebookEditorModel extends EditorModel { private _dirty: boolean; @@ -322,14 +326,16 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu await this.updateModel(); let input = await this.textInput.save(groupId, options); await this.setTrustForNewEditor(input); - return input; + const langAssociation = languageAssociationRegistry.getAssociationForLanguage(NotebookLanguage.Ipynb); + return langAssociation.convertInput(input); } override async saveAs(group: number, options?: ITextFileSaveOptions): Promise { await this.updateModel(); let input = await this.textInput.saveAs(group, options); await this.setTrustForNewEditor(input); - return input; + const langAssociation = languageAssociationRegistry.getAssociationForLanguage(NotebookLanguage.Ipynb); + return langAssociation.convertInput(input); } private async setTrustForNewEditor(newInput: IEditorInput | undefined): Promise {