diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts index 2f773b8436c..5381bc67978 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts @@ -68,9 +68,9 @@ const kernel1 = new class implements vscode.NotebookKernel { } task.start(); - await task.replaceOutput([new vscode.NotebookCellOutput([ + await task.replaceOutput(new vscode.NotebookCellOutput([ new vscode.NotebookCellOutputItem('text/plain', ['my output'], undefined) - ])]); + ])); task.end({ success: true }); return; } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 3fd5e086bd6..407f4ad13b4 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1573,8 +1573,8 @@ declare module 'vscode' { readonly token: CancellationToken; clearOutput(cellIndex?: number): Thenable; - appendOutput(out: NotebookCellOutput[], cellIndex?: number): Thenable; - replaceOutput(out: NotebookCellOutput[], 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; } diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index d06967d37ea..30c639ad64f 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -1164,23 +1164,25 @@ class NotebookCellExecutionTask extends Disposable { return this.replaceOutput([], cellIndex); }, - async appendOutput(outputs: vscode.NotebookCellOutput[], cellIndex?: number): Promise { + async appendOutput(outputs: vscode.NotebookCellOutput | vscode.NotebookCellOutput[], cellIndex?: number): Promise { that.verifyStateForOutput(); const handle = that.cellIndexToHandle(cellIndex); if (typeof handle !== 'number') { return; } + outputs = Array.isArray(outputs) ? outputs : [outputs]; return that.applyEdits([{ editType: CellEditType.Output, handle, append: true, outputs: outputs.map(typeConverters.NotebookCellOutput.from) }]); }, - async replaceOutput(outputs: vscode.NotebookCellOutput[], cellIndex?: number): Promise { + async replaceOutput(outputs: vscode.NotebookCellOutput | vscode.NotebookCellOutput[], cellIndex?: number): Promise { that.verifyStateForOutput(); const handle = that.cellIndexToHandle(cellIndex); if (typeof handle !== 'number') { return; } + outputs = Array.isArray(outputs) ? outputs : [outputs]; return that.applyEdits([{ editType: CellEditType.Output, handle, outputs: outputs.map(typeConverters.NotebookCellOutput.from) }]); },