From 8006b8c9a49792d5350ef2da2b6e44cbb0b310ff Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 7 Jun 2021 17:47:34 +0200 Subject: [PATCH] make getEditorById strict --- src/vs/workbench/api/common/extHostNotebook.ts | 10 ++-------- src/vs/workbench/api/common/extHostNotebookEditors.ts | 4 ++-- src/vs/workbench/api/common/extHostNotebookKernels.ts | 4 ---- .../workbench/api/common/extHostNotebookRenderers.ts | 4 ---- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 3646ae59882..f846afde578 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -106,20 +106,14 @@ export class ExtHostNotebookController implements ExtHostNotebookShape { }); } - getEditorById(editorId: string, strict: true): ExtHostNotebookEditor; - getEditorById(editorId: string): ExtHostNotebookEditor | undefined; - getEditorById(editorId: string, strict?: true): ExtHostNotebookEditor | undefined { + getEditorById(editorId: string): ExtHostNotebookEditor { const editor = this._editors.get(editorId); - if (!editor && strict) { + if (!editor) { throw new Error(`unknown text editor: ${editorId}. known editors: ${[...this._editors.keys()]} `); } return editor; } - allEditors(): ExtHostNotebookEditor[] { - return [...this._editors.values()]; - } - getIdByEditor(editor: vscode.NotebookEditor): string | undefined { for (const [id, candidate] of this._editors) { if (candidate.apiEditor === editor) { diff --git a/src/vs/workbench/api/common/extHostNotebookEditors.ts b/src/vs/workbench/api/common/extHostNotebookEditors.ts index 993a5226a3b..6e70ab1c882 100644 --- a/src/vs/workbench/api/common/extHostNotebookEditors.ts +++ b/src/vs/workbench/api/common/extHostNotebookEditors.ts @@ -55,7 +55,7 @@ export class ExtHostNotebookEditors implements ExtHostNotebookEditorsShape { $acceptEditorPropertiesChanged(id: string, data: INotebookEditorPropertiesChangeData): void { this._logService.debug('ExtHostNotebook#$acceptEditorPropertiesChanged', id, data); - const editor = this._notebooksAndEditors.getEditorById(id, true); + const editor = this._notebooksAndEditors.getEditorById(id); // ONE: make all state updates if (data.visibleRanges) { editor._acceptVisibleRanges(data.visibleRanges.ranges.map(typeConverters.NotebookRange.to)); @@ -81,7 +81,7 @@ export class ExtHostNotebookEditors implements ExtHostNotebookEditorsShape { $acceptEditorViewColumns(data: INotebookEditorViewColumnInfo): void { for (const id in data) { - const editor = this._notebooksAndEditors.getEditorById(id, true); + const editor = this._notebooksAndEditors.getEditorById(id); editor._acceptViewColumn(typeConverters.ViewColumn.to(data[id])); } } diff --git a/src/vs/workbench/api/common/extHostNotebookKernels.ts b/src/vs/workbench/api/common/extHostNotebookKernels.ts index 8af73f0f1da..47811e753af 100644 --- a/src/vs/workbench/api/common/extHostNotebookKernels.ts +++ b/src/vs/workbench/api/common/extHostNotebookKernels.ts @@ -286,10 +286,6 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape { } const editor = this._extHostNotebook.getEditorById(editorId); - if (!editor) { - throw new Error(`send message for UNKNOWN editor: ${editorId}`); - } - obj.onDidReceiveMessage.fire(Object.freeze({ editor: editor.apiEditor, message })); } diff --git a/src/vs/workbench/api/common/extHostNotebookRenderers.ts b/src/vs/workbench/api/common/extHostNotebookRenderers.ts index fcf5eb9cfd5..c134a73994f 100644 --- a/src/vs/workbench/api/common/extHostNotebookRenderers.ts +++ b/src/vs/workbench/api/common/extHostNotebookRenderers.ts @@ -19,10 +19,6 @@ export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape { public $postRendererMessage(editorId: string, rendererId: string, message: unknown): void { const editor = this._extHostNotebook.getEditorById(editorId); - if (!editor) { - return; - } - this._rendererMessageEmitters.get(rendererId)?.fire({ editor: editor.apiEditor, message }); }