From 39da966de35bcef31637510c46bafe8b2c68ebc7 Mon Sep 17 00:00:00 2001 From: aamunger Date: Wed, 25 Jan 2023 10:28:07 -0800 Subject: [PATCH 1/2] don't recovery notebook editors from IW notebooks. don't recover backups for new IW notebook models --- .../contrib/notebook/browser/notebook.contribution.ts | 2 +- .../contrib/notebook/common/notebookEditorModel.ts | 10 ++++++++-- 2 files changed, 9 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 9b0857c9c5cf1..18d3062d731e9 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -613,7 +613,7 @@ class SimpleNotebookWorkingCopyEditorHandler extends Disposable implements IWork await this._extensionService.whenInstalledExtensionsRegistered(); this._register(this._workingCopyEditorService.registerHandler({ - handles: workingCopy => typeof this._getViewType(workingCopy) === 'string', + handles: workingCopy => typeof this._getViewType(workingCopy) && workingCopy.resource.scheme !== Schemas.vscodeInteractive, isOpen: (workingCopy, editor) => editor instanceof NotebookEditorInput && editor.viewType === this._getViewType(workingCopy) && isEqual(workingCopy.resource, editor.resource), createEditor: workingCopy => NotebookEditorInput.create(this._instantiationService, workingCopy.resource, this._getViewType(workingCopy)!) })); diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts index f693c18cafb2f..e3e174aadfb7c 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts @@ -252,8 +252,14 @@ export class NotebookFileWorkingCopyModelFactory implements IStoredFileWorkingCo throw new Error('CANNOT open file notebook with this provider'); } - const bytes = await streamToBuffer(stream); - const data = await info.serializer.dataToNotebook(bytes); + let data: NotebookData = { + metadata: {}, + cells: [] + }; + if (resource.scheme !== Schemas.vscodeInteractive) { + const bytes = await streamToBuffer(stream); + data = await info.serializer.dataToNotebook(bytes); + } if (token.isCancellationRequested) { throw new CancellationError(); From f16ff38c40c5505347302fd289b9a735c5bba3f9 Mon Sep 17 00:00:00 2001 From: aamunger Date: Wed, 25 Jan 2023 11:03:39 -0800 Subject: [PATCH 2/2] check viewtype, is string, not interactive --- .../contrib/notebook/browser/notebook.contribution.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 18d3062d731e9..4521abd7ed4f5 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -613,7 +613,10 @@ class SimpleNotebookWorkingCopyEditorHandler extends Disposable implements IWork await this._extensionService.whenInstalledExtensionsRegistered(); this._register(this._workingCopyEditorService.registerHandler({ - handles: workingCopy => typeof this._getViewType(workingCopy) && workingCopy.resource.scheme !== Schemas.vscodeInteractive, + handles: workingCopy => { + const viewType = this._getViewType(workingCopy); + return typeof viewType === 'string' && viewType !== 'interactive'; + }, isOpen: (workingCopy, editor) => editor instanceof NotebookEditorInput && editor.viewType === this._getViewType(workingCopy) && isEqual(workingCopy.resource, editor.resource), createEditor: workingCopy => NotebookEditorInput.create(this._instantiationService, workingCopy.resource, this._getViewType(workingCopy)!) }));