From c5a8eed033438abf6b737fcd0c8e3eba005159e5 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Thu, 25 Mar 2021 09:39:09 -0700 Subject: [PATCH] Accept array or single item for output items methods #119601 --- src/vs/vscode.proposed.d.ts | 4 ++-- src/vs/workbench/api/common/extHostNotebook.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 407f4ad13b4..145bed60c4a 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1575,8 +1575,8 @@ declare module 'vscode' { clearOutput(cellIndex?: number): Thenable; appendOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable; replaceOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable; - appendOutputItems(items: NotebookCellOutputItem[], outputId: string): Thenable; - replaceOutputItems(items: NotebookCellOutputItem[], outputId: string): Thenable; + appendOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable; + replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable; } export enum NotebookCellExecutionState { diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index 30c639ad64f..62cde72eb53 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -1186,13 +1186,15 @@ class NotebookCellExecutionTask extends Disposable { return that.applyEdits([{ editType: CellEditType.Output, handle, outputs: outputs.map(typeConverters.NotebookCellOutput.from) }]); }, - async appendOutputItems(items: vscode.NotebookCellOutputItem[], outputId: string): Promise { + async appendOutputItems(items: vscode.NotebookCellOutputItem | vscode.NotebookCellOutputItem[], outputId: string): Promise { that.verifyStateForOutput(); + items = Array.isArray(items) ? items : [items]; return that.applyEdits([{ editType: CellEditType.OutputItems, append: true, items: items.map(typeConverters.NotebookCellOutputItem.from), outputId }]); }, - async replaceOutputItems(items: vscode.NotebookCellOutputItem[], outputId: string): Promise { + async replaceOutputItems(items: vscode.NotebookCellOutputItem | vscode.NotebookCellOutputItem[], outputId: string): Promise { that.verifyStateForOutput(); + items = Array.isArray(items) ? items : [items]; return that.applyEdits([{ editType: CellEditType.OutputItems, items: items.map(typeConverters.NotebookCellOutputItem.from), outputId }]); },