mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 11:10:48 +00:00
Accept single outputs or arrays in execution task output edit methods
Fix #119601
This commit is contained in:
parent
75ed057885
commit
1a425eacb8
3 changed files with 8 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
4
src/vs/vscode.proposed.d.ts
vendored
4
src/vs/vscode.proposed.d.ts
vendored
|
@ -1573,8 +1573,8 @@ declare module 'vscode' {
|
|||
readonly token: CancellationToken;
|
||||
|
||||
clearOutput(cellIndex?: number): Thenable<void>;
|
||||
appendOutput(out: NotebookCellOutput[], cellIndex?: number): Thenable<void>;
|
||||
replaceOutput(out: NotebookCellOutput[], cellIndex?: number): Thenable<void>;
|
||||
appendOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
|
||||
replaceOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
|
||||
appendOutputItems(items: NotebookCellOutputItem[], outputId: string): Thenable<void>;
|
||||
replaceOutputItems(items: NotebookCellOutputItem[], outputId: string): Thenable<void>;
|
||||
}
|
||||
|
|
|
@ -1164,23 +1164,25 @@ class NotebookCellExecutionTask extends Disposable {
|
|||
return this.replaceOutput([], cellIndex);
|
||||
},
|
||||
|
||||
async appendOutput(outputs: vscode.NotebookCellOutput[], cellIndex?: number): Promise<void> {
|
||||
async appendOutput(outputs: vscode.NotebookCellOutput | vscode.NotebookCellOutput[], cellIndex?: number): Promise<void> {
|
||||
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<void> {
|
||||
async replaceOutput(outputs: vscode.NotebookCellOutput | vscode.NotebookCellOutput[], cellIndex?: number): Promise<void> {
|
||||
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) }]);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue