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
This commit is contained in:
Maddy
2022-01-24 14:17:34 -08:00
committed by GitHub
parent 3eff450322
commit bf5f18ea72
2 changed files with 3 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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