From 23f5231511deb86ed3520e8374a0e648b0bdba42 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 20 May 2020 12:17:26 -0700 Subject: [PATCH] asWebvewUri requires guid. --- src/vs/workbench/api/browser/mainThreadNotebook.ts | 4 ++++ src/vs/workbench/api/common/extHostNotebook.ts | 4 +++- .../contrib/notebook/browser/notebookEditorWidget.ts | 8 ++------ .../workbench/contrib/notebook/common/notebookCommon.ts | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadNotebook.ts b/src/vs/workbench/api/browser/mainThreadNotebook.ts index b678715f24b..e9f673616bf 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebook.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebook.ts @@ -377,6 +377,7 @@ export class MainThreadNotebookController implements IMainNotebookController { { editType: CellEditType.Delete, count: mainthreadNotebook.textModel.cells.length, index: 0 }, { editType: CellEditType.Insert, index: 0, cells: data.cells } ]); + mainthreadNotebook.textModel.updateRenderers(data.renderers); } return mainthreadNotebook.textModel; } @@ -397,6 +398,8 @@ export class MainThreadNotebookController implements IMainNotebookController { } ]); + // TODO@rebornix load renderers after reloading + this._mainThreadNotebook.addNotebookDocument({ viewType: document.viewType, handle: document.handle, @@ -429,6 +432,7 @@ export class MainThreadNotebookController implements IMainNotebookController { document.textModel.languages = data.languages; document.textModel.metadata = data.metadata; + document.textModel.updateRenderers(data.renderers); if (data.cells.length) { document.textModel.initialize(data!.cells); diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 19148d3653b..f351207b2ac 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -891,9 +891,11 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN source: cell.source, outputs: transformedOutputs }; - }) + }), + renderers: [] as number[] }; + dto.renderers = [...renderers]; return dto; } diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts index b3dcc814068..2aeaf676287 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts @@ -67,9 +67,6 @@ export class NotebookEditorOptions extends EditorOptions { } } - -let EDITOR_ID = 0; - export class NotebookEditorWidget extends Disposable implements INotebookEditor { static readonly ID: string = 'workbench.editor.notebook'; private static readonly EDITOR_MEMENTOS = new Map>(); @@ -95,7 +92,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor private scrollBeyondLastLine: boolean; private readonly memento: Memento; private _isDisposed: boolean = false; - private readonly _id: number; constructor( @IInstantiationService private readonly instantiationService: IInstantiationService, @IStorageService storageService: IStorageService, @@ -105,7 +101,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor @ILayoutService private readonly _layoutService: ILayoutService ) { super(); - this._id = (++EDITOR_ID); this.memento = new Memento(NotebookEditorWidget.ID, storageService); this.outputRenderer = new OutputRenderer(this, this.instantiationService); @@ -124,8 +119,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor this.notebookService.addNotebookEditor(this); } + private _uuid = generateUuid(); public getId(): string { - return 'vs.editor.INotebookEditor:' + this._id; + return this._uuid; } private readonly _onDidChangeModel = new Emitter(); diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index af806c559ea..adf18a3d975 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -329,6 +329,7 @@ export interface NotebookDataDto { readonly cells: ICellDto2[]; readonly languages: string[]; readonly metadata: NotebookDocumentMetadata; + readonly renderers: number[]; } -- GitLab