diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 28465f58328..e63bf113d3c 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1201,13 +1201,6 @@ declare module 'vscode' { * The column in which this editor shows. */ readonly viewColumn?: ViewColumn; - - /** - * @deprecated - */ - // @rebornix REMOVE/REplace NotebookCommunication - // todo@API fishy? notebooks are public objects, there should be a "global" events for this - readonly onDidDispose: Event; } export interface NotebookDocumentMetadataChangeEvent { diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index f156c720cf0..974ee0762c2 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -669,6 +669,11 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { } private _createExtHostEditor(document: ExtHostNotebookDocument, editorId: string, data: INotebookEditorAddData) { + + if (this._editors.has(editorId)) { + throw new Error(`editor with id ALREADY EXSIST: ${editorId}`); + } + const revivedUri = document.uri; let webComm = this._webviewComm.get(editorId); @@ -686,13 +691,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { typeof data.viewColumn === 'number' ? typeConverters.ViewColumn.to(data.viewColumn) : undefined ); - - this._editors.get(editorId)?.editor.dispose(); this._editors.set(editorId, { editor }); } $acceptDocumentAndEditorsDelta(delta: INotebookDocumentsAndEditorsDelta): void { - let editorChanged = false; if (delta.removedDocuments) { for (const uri of delta.removedDocuments) { @@ -708,9 +710,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { for (const e of this._editors.values()) { if (e.editor.notebookData.uri.toString() === revivedUri.toString()) { - e.editor.dispose(); this._editors.delete(e.editor.id); - editorChanged = true; } } } @@ -782,7 +782,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { if (document) { this._createExtHostEditor(document, editorModelData.id, editorModelData); - editorChanged = true; } } } @@ -794,7 +793,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { const editor = this._editors.get(editorid); if (editor) { - editorChanged = true; this._editors.delete(editorid); if (this._activeNotebookEditor?.id === editor.editor.id) { @@ -806,12 +804,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { } } - if (editorChanged) { - removedEditors.forEach(e => { - e.editor.dispose(); - }); - } - if (delta.visibleEditors) { this._visibleNotebookEditors = delta.visibleEditors.map(id => this._editors.get(id)!.editor).filter(editor => !!editor) as ExtHostNotebookEditor[]; const visibleEditorsSet = new Set(); diff --git a/src/vs/workbench/api/common/extHostNotebookEditor.ts b/src/vs/workbench/api/common/extHostNotebookEditor.ts index 0430d67ca7b..f17a7416ee2 100644 --- a/src/vs/workbench/api/common/extHostNotebookEditor.ts +++ b/src/vs/workbench/api/common/extHostNotebookEditor.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Emitter, Event } from 'vs/base/common/event'; import { MainThreadNotebookEditorsShape } from 'vs/workbench/api/common/extHost.protocol'; import * as extHostTypes from 'vs/workbench/api/common/extHostTypes'; import * as extHostConverter from 'vs/workbench/api/common/extHostTypeConverters'; @@ -93,9 +92,6 @@ export class ExtHostNotebookEditor { private _kernel?: vscode.NotebookKernel; private readonly _hasDecorationsForKey = new Set(); - private readonly _onDidDispose = new Emitter(); - readonly onDidDispose: Event = this._onDidDispose.event; - private _editor?: vscode.NotebookEditor; @@ -112,11 +108,6 @@ export class ExtHostNotebookEditor { this._viewColumn = viewColumn; } - dispose() { - this._onDidDispose.fire(); - this._onDidDispose.dispose(); - } - get editor(): vscode.NotebookEditor { if (!this._editor) { const that = this; @@ -144,9 +135,6 @@ export class ExtHostNotebookEditor { get viewColumn() { return that._viewColumn; }, - get onDidDispose() { - return that.onDidDispose; - }, edit(callback) { const edit = new NotebookEditorCellEditBuilder(this.document.version); callback(edit);