Correctly handle creating and saving untitled notebook .dib files. (#18744)

This commit is contained in:
Cory Rivera
2022-03-16 14:37:21 -07:00
committed by GitHub
parent 8cc0fdfdc5
commit 95980130c8
11 changed files with 72 additions and 27 deletions

View File

@@ -447,7 +447,11 @@ export abstract class NotebookInput extends EditorInput implements INotebookInpu
private async assignProviders(): Promise<void> {
await this.extensionService.whenInstalledExtensionsRegistered();
let providerIds: string[] = getProvidersForFileName(this._title, this.notebookService);
let mode: string;
if (this._textInput instanceof UntitledTextEditorInput) {
mode = this._textInput.model.getMode();
}
let providerIds: string[] = getProvidersForFileName(this._title, this.notebookService, mode);
if (providerIds && providerIds.length > 0) {
this._providerId = providerIds.filter(provider => provider !== DEFAULT_NOTEBOOK_PROVIDER)[0];
this._providers = providerIds;

View File

@@ -27,7 +27,7 @@ export class UntitledNotebookInput extends NotebookInput {
) {
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'));
this.textInput.resolve().then(() => this.setMode(textInput.model.getMode()));
}
public override get textInput(): UntitledTextEditorInput {