From 0dbb92c62f3cc335c6a104dcaf58523717c88ab5 Mon Sep 17 00:00:00 2001 From: Dennis Huebner Date: Fri, 9 Aug 2024 15:17:27 +0200 Subject: [PATCH] Creating new untitled document doesn't work --- .../service/notebook-model-resolver-service.ts | 11 +++++++++-- .../main/browser/notebooks/notebook-documents-main.ts | 5 ----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/notebook/src/browser/service/notebook-model-resolver-service.ts b/packages/notebook/src/browser/service/notebook-model-resolver-service.ts index 949fc0b779621..731a344f9a543 100644 --- a/packages/notebook/src/browser/service/notebook-model-resolver-service.ts +++ b/packages/notebook/src/browser/service/notebook-model-resolver-service.ts @@ -18,7 +18,7 @@ import { Emitter, Resource, ResourceProvider, UNTITLED_SCHEME, URI } from '@thei import { inject, injectable } from '@theia/core/shared/inversify'; import { UriComponents } from '@theia/core/lib/common/uri'; import { FileService } from '@theia/filesystem/lib/browser/file-service'; -import { NotebookData } from '../../common'; +import { CellKind, NotebookData } from '../../common'; import { NotebookModel } from '../view-model/notebook-model'; import { NotebookService } from './notebook-service'; import { NotebookTypeRegistry } from '../notebook-type-registry'; @@ -111,7 +111,14 @@ export class NotebookModelResolverService { async resolveExistingNotebookData(resource: Resource, viewType: string): Promise { if (resource.uri.scheme === 'untitled') { return { - cells: [], + cells: [ + { + cellKind: CellKind.Code, + language: 'plaintext', + source: 'Untitled notebook', + outputs: [] + } + ], metadata: {} }; } else { diff --git a/packages/plugin-ext/src/main/browser/notebooks/notebook-documents-main.ts b/packages/plugin-ext/src/main/browser/notebooks/notebook-documents-main.ts index 427e0a009b627..6ad0538edc5e8 100644 --- a/packages/plugin-ext/src/main/browser/notebooks/notebook-documents-main.ts +++ b/packages/plugin-ext/src/main/browser/notebooks/notebook-documents-main.ts @@ -159,11 +159,6 @@ export class NotebookDocumentsMainImpl implements NotebookDocumentsMain { // untitled notebooks are dirty by default this.proxy.$acceptDirtyStateChanged(ref.uri.toComponents(), true); - // apply content changes... slightly HACKY -> this triggers a change event - if (options.content) { - const data = NotebookDto.fromNotebookDataDto(options.content); - ref.setData(data); - } return ref.uri.toComponents(); }