From 6887b60949491a0f94b738e4d091c7d5d09c0cce Mon Sep 17 00:00:00 2001 From: rebornix Date: Tue, 15 Sep 2020 10:03:19 -0700 Subject: [PATCH] resolve the right view type of a cell when its containing document is already opened. --- .../notebook/browser/notebook.contribution.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 28ed42f3b1a..e13566c70d4 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -446,12 +446,20 @@ class CellContentProvider implements ITextModelContentProvider { if (!data) { return null; } - const info = getFirstNotebookInfo(this._notebookService, data.notebook); - if (!info) { + + const documentAlreadyOpened = this._notebookService.listNotebookDocuments().find(document => document.uri.toString() === data.notebook.toString()); + let viewType = documentAlreadyOpened?.viewType; + + if (!viewType) { + const info = getFirstNotebookInfo(this._notebookService, data.notebook); + viewType = info?.id; + } + + if (!viewType) { return null; } - const ref = await this._notebookModelResolverService.resolve(data.notebook, info.id); + const ref = await this._notebookModelResolverService.resolve(data.notebook, viewType); let result: ITextModel | null = null; for (const cell of ref.object.notebook.cells) { -- GitLab