mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix untitled notebook save opening as JSON (#18156)
This commit is contained in:
@@ -37,8 +37,12 @@ import { INotebookInput } from 'sql/workbench/services/notebook/browser/interfac
|
|||||||
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
|
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
|
||||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||||
import { LocalContentManager } from 'sql/workbench/services/notebook/common/localContentManager';
|
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<boolean>;
|
export type ModeViewSaveHandler = (handle: number) => Thenable<boolean>;
|
||||||
|
const languageAssociationRegistry = Registry.as<ILanguageAssociationRegistry>(LanguageAssociationExtensions.LanguageAssociations);
|
||||||
|
|
||||||
export class NotebookEditorModel extends EditorModel {
|
export class NotebookEditorModel extends EditorModel {
|
||||||
private _dirty: boolean;
|
private _dirty: boolean;
|
||||||
@@ -322,14 +326,16 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
|
|||||||
await this.updateModel();
|
await this.updateModel();
|
||||||
let input = await this.textInput.save(groupId, options);
|
let input = await this.textInput.save(groupId, options);
|
||||||
await this.setTrustForNewEditor(input);
|
await this.setTrustForNewEditor(input);
|
||||||
return input;
|
const langAssociation = languageAssociationRegistry.getAssociationForLanguage(NotebookLanguage.Ipynb);
|
||||||
|
return langAssociation.convertInput(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
override async saveAs(group: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
override async saveAs(group: number, options?: ITextFileSaveOptions): Promise<IEditorInput | undefined> {
|
||||||
await this.updateModel();
|
await this.updateModel();
|
||||||
let input = await this.textInput.saveAs(group, options);
|
let input = await this.textInput.saveAs(group, options);
|
||||||
await this.setTrustForNewEditor(input);
|
await this.setTrustForNewEditor(input);
|
||||||
return input;
|
const langAssociation = languageAssociationRegistry.getAssociationForLanguage(NotebookLanguage.Ipynb);
|
||||||
|
return langAssociation.convertInput(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setTrustForNewEditor(newInput: IEditorInput | undefined): Promise<void> {
|
private async setTrustForNewEditor(newInput: IEditorInput | undefined): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user