mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
rename NotebookCellOutput#outputs to #items
This commit is contained in:
parent
d9f1e27aeb
commit
4202ab071a
|
@ -475,10 +475,11 @@ suite('Notebook API tests', function () {
|
|||
const secondCell = vscode.window.activeNotebookEditor!.document.cellAt(1);
|
||||
assert.strictEqual(secondCell!.outputs.length, 1);
|
||||
assert.deepStrictEqual(secondCell!.outputs[0].metadata, { testOutputMetadata: true });
|
||||
assert.strictEqual(secondCell!.outputs[0].outputs.length, 1);
|
||||
assert.strictEqual(secondCell!.outputs[0].outputs[0].mime, 'text/plain');
|
||||
assert.strictEqual(new TextDecoder().decode(secondCell!.outputs[0].outputs[0].data), 'Hello World');
|
||||
assert.deepStrictEqual(secondCell!.outputs[0].outputs[0].metadata, { testOutputItemMetadata: true });
|
||||
assert.strictEqual((<any>secondCell!.outputs[0]).outputs.length, 1); //todo@jrieken will FAIL once the backwards compatibility is gone
|
||||
assert.strictEqual(secondCell!.outputs[0].items.length, 1);
|
||||
assert.strictEqual(secondCell!.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.strictEqual(new TextDecoder().decode(secondCell!.outputs[0].items[0].data), 'Hello World');
|
||||
assert.deepStrictEqual(secondCell!.outputs[0].items[0].metadata, { testOutputItemMetadata: true });
|
||||
assert.strictEqual(secondCell!.executionSummary?.executionOrder, 5);
|
||||
assert.strictEqual(secondCell!.executionSummary?.success, true);
|
||||
|
||||
|
@ -746,9 +747,9 @@ suite('Notebook API tests', function () {
|
|||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].outputs[0].data), 'my output');
|
||||
assert.strictEqual(cell.outputs[0].items.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].items[0].data), 'my output');
|
||||
});
|
||||
|
||||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
|
@ -756,9 +757,9 @@ suite('Notebook API tests', function () {
|
|||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].outputs[0].data), 'my second output');
|
||||
assert.strictEqual(cell.outputs[0].items.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].items[0].data), 'my second output');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -796,9 +797,9 @@ suite('Notebook API tests', function () {
|
|||
await vscode.commands.executeCommand('notebook.cell.cancelExecution');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].outputs[0].data), 'Canceled');
|
||||
assert.strictEqual(cell.outputs[0].items.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].items[0].data), 'Canceled');
|
||||
});
|
||||
|
||||
cancelableKernel.controller.dispose();
|
||||
|
@ -838,9 +839,9 @@ suite('Notebook API tests', function () {
|
|||
await vscode.commands.executeCommand('notebook.cell.cancelExecution');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].outputs[0].data), 'Interrupted');
|
||||
assert.strictEqual(cell.outputs[0].items.length, 1);
|
||||
assert.strictEqual(cell.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.outputs[0].items[0].data), 'Interrupted');
|
||||
});
|
||||
|
||||
interruptableKernel.controller.dispose();
|
||||
|
@ -1184,7 +1185,7 @@ suite('Notebook API tests', function () {
|
|||
vscode.NotebookCellOutputItem.text('Some output', 'text/plain', undefined)
|
||||
])]);
|
||||
assert.strictEqual(cell.notebook.cellAt(0).outputs.length, 1);
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.notebook.cellAt(0).outputs[0].outputs[0].data), 'Some output');
|
||||
assert.deepStrictEqual(new TextDecoder().decode(cell.notebook.cellAt(0).outputs[0].items[0].data), 'Some output');
|
||||
task.end({});
|
||||
called = true;
|
||||
}
|
||||
|
|
3
src/vs/vscode.proposed.d.ts
vendored
3
src/vs/vscode.proposed.d.ts
vendored
|
@ -1403,8 +1403,7 @@ declare module 'vscode' {
|
|||
* ])
|
||||
* ```
|
||||
*/
|
||||
//todo@API rename to items
|
||||
outputs: NotebookCellOutputItem[];
|
||||
items: NotebookCellOutputItem[];
|
||||
|
||||
//todo@API have this OR NotebookCellOutputItem#metadata but not both? Preference for this.
|
||||
metadata?: { [key: string]: any };
|
||||
|
|
|
@ -44,7 +44,7 @@ export class ExtHostCell {
|
|||
};
|
||||
}
|
||||
|
||||
private _outputs: extHostTypes.NotebookCellOutput[];
|
||||
private _outputs: vscode.NotebookCellOutput[];
|
||||
private _metadata: extHostTypes.NotebookCellMetadata;
|
||||
private _previousResult: vscode.NotebookCellExecutionSummary | undefined;
|
||||
|
||||
|
@ -102,9 +102,9 @@ export class ExtHostCell {
|
|||
const output = this._outputs.find(op => op.id === outputId);
|
||||
if (output) {
|
||||
if (!append) {
|
||||
output.outputs.length = 0;
|
||||
output.items.length = 0;
|
||||
}
|
||||
output.outputs.push(...newItems);
|
||||
output.items.push(...newItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -397,12 +397,12 @@ class NotebookCellExecutionTask extends Disposable {
|
|||
|
||||
private validateAndConvertOutputs(items: vscode.NotebookCellOutput[]): IOutputDto[] {
|
||||
return items.map(output => {
|
||||
const newOutput = NotebookCellOutput.ensureUniqueMimeTypes(output.outputs, true);
|
||||
if (newOutput === output.outputs) {
|
||||
const newOutput = NotebookCellOutput.ensureUniqueMimeTypes(output.items, true);
|
||||
if (newOutput === output.items) {
|
||||
return extHostTypeConverters.NotebookCellOutput.from(output);
|
||||
}
|
||||
return extHostTypeConverters.NotebookCellOutput.from({
|
||||
outputs: newOutput,
|
||||
items: newOutput,
|
||||
id: output.id,
|
||||
metadata: output.metadata
|
||||
});
|
||||
|
|
|
@ -1547,10 +1547,10 @@ export namespace NotebookCellOutputItem {
|
|||
}
|
||||
|
||||
export namespace NotebookCellOutput {
|
||||
export function from(output: types.NotebookCellOutput): notebooks.IOutputDto {
|
||||
export function from(output: vscode.NotebookCellOutput): notebooks.IOutputDto {
|
||||
return {
|
||||
outputId: output.id,
|
||||
outputs: output.outputs.map(NotebookCellOutputItem.from),
|
||||
outputs: output.items.map(NotebookCellOutputItem.from),
|
||||
metadata: output.metadata
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3075,11 +3075,11 @@ export class NotebookCellData {
|
|||
kind: NotebookCellKind;
|
||||
value: string;
|
||||
languageId: string;
|
||||
outputs?: NotebookCellOutput[];
|
||||
outputs?: vscode.NotebookCellOutput[];
|
||||
metadata?: NotebookCellMetadata;
|
||||
executionSummary?: vscode.NotebookCellExecutionSummary;
|
||||
|
||||
constructor(kind: NotebookCellKind, value: string, languageId: string, outputs?: NotebookCellOutput[], metadata?: NotebookCellMetadata, executionSummary?: vscode.NotebookCellExecutionSummary) {
|
||||
constructor(kind: NotebookCellKind, value: string, languageId: string, outputs?: vscode.NotebookCellOutput[], metadata?: NotebookCellMetadata, executionSummary?: vscode.NotebookCellExecutionSummary) {
|
||||
this.kind = kind;
|
||||
this.value = value;
|
||||
this.languageId = languageId;
|
||||
|
@ -3164,14 +3164,14 @@ export class NotebookCellOutputItem {
|
|||
|
||||
export class NotebookCellOutput {
|
||||
|
||||
static isNotebookCellOutput(candidate: any): candidate is NotebookCellOutput {
|
||||
static isNotebookCellOutput(candidate: any): candidate is vscode.NotebookCellOutput {
|
||||
if (candidate instanceof NotebookCellOutput) {
|
||||
return true;
|
||||
}
|
||||
if (!candidate || typeof candidate !== 'object') {
|
||||
return false;
|
||||
}
|
||||
return typeof (<NotebookCellOutput>candidate).id === 'string' && isArray((<NotebookCellOutput>candidate).outputs);
|
||||
return typeof (<NotebookCellOutput>candidate).id === 'string' && isArray((<NotebookCellOutput>candidate).items);
|
||||
}
|
||||
|
||||
static ensureUniqueMimeTypes(items: NotebookCellOutputItem[], warn: boolean = false): NotebookCellOutputItem[] {
|
||||
|
@ -3197,15 +3197,18 @@ export class NotebookCellOutput {
|
|||
}
|
||||
|
||||
id: string;
|
||||
outputs: NotebookCellOutputItem[];
|
||||
items: NotebookCellOutputItem[];
|
||||
metadata?: Record<string, any>;
|
||||
|
||||
get outputs() { return this.items; }
|
||||
set outputs(value) { this.items = value; }
|
||||
|
||||
constructor(
|
||||
outputs: NotebookCellOutputItem[],
|
||||
items: NotebookCellOutputItem[],
|
||||
idOrMetadata?: string | Record<string, any>,
|
||||
metadata?: Record<string, any>
|
||||
) {
|
||||
this.outputs = NotebookCellOutput.ensureUniqueMimeTypes(outputs, true);
|
||||
this.items = NotebookCellOutput.ensureUniqueMimeTypes(items, true);
|
||||
if (typeof idOrMetadata === 'string') {
|
||||
this.id = idOrMetadata;
|
||||
this.metadata = metadata;
|
||||
|
|
Loading…
Reference in a new issue