This commit is contained in:
Johannes Rieken 2020-09-25 18:04:10 +02:00
parent 2fc01432c1
commit 1e7454f72a
6 changed files with 20 additions and 22 deletions

View file

@ -423,9 +423,9 @@ suite('Notebook API tests', () => {
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
await vscode.notebook.activeNotebookEditor!.edit(editBuilder => { await vscode.notebook.activeNotebookEditor!.edit(editBuilder => {
editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutputList([ editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutput([
new vscode.NotebookCellOutput('application/foo', 'bar'), new vscode.NotebookCellOutputItem('application/foo', 'bar'),
new vscode.NotebookCellOutput('application/json', { data: true }, { metadata: true }), new vscode.NotebookCellOutputItem('application/json', { data: true }, { metadata: true }),
])]); ])]);
}); });

View file

@ -1226,8 +1226,7 @@ declare module 'vscode' {
export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput; export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput;
//TODO@jrieken rename to NotebookCellOutputItem export class NotebookCellOutputItem {
export class NotebookCellOutput {
readonly mime: string; readonly mime: string;
readonly value: unknown; readonly value: unknown;
@ -1236,14 +1235,13 @@ declare module 'vscode' {
constructor(mime: string, value: unknown, metadata?: Record<string, string | number | boolean>); constructor(mime: string, value: unknown, metadata?: Record<string, string | number | boolean>);
} }
//TODO@jrieken rename to NotebookCellOutput
//TODO@jrieken add id? //TODO@jrieken add id?
export class NotebookCellOutputList { export class NotebookCellOutput {
readonly outputs: NotebookCellOutput[]; readonly outputs: NotebookCellOutputItem[];
readonly metadata?: Record<string, string | number | boolean>; readonly metadata?: Record<string, string | number | boolean>;
constructor(outputs: NotebookCellOutput[], metadata?: Record<string, string | number | boolean>); constructor(outputs: NotebookCellOutputItem[], metadata?: Record<string, string | number | boolean>);
} }
export enum NotebookCellRunState { export enum NotebookCellRunState {
@ -1434,7 +1432,7 @@ declare module 'vscode' {
export interface NotebookEditorEdit { export interface NotebookEditorEdit {
replaceMetadata(value: NotebookDocumentMetadata): void; replaceMetadata(value: NotebookDocumentMetadata): void;
replaceCells(start: number, end: number, cells: NotebookCellData[]): void; replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
replaceCellOutput(index: number, outputs: (NotebookCellOutputList | CellOutput)[]): void; replaceCellOutput(index: number, outputs: (NotebookCellOutput | CellOutput)[]): void;
replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void; replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
} }

View file

@ -1148,8 +1148,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
NotebookRunState: extHostTypes.NotebookRunState, NotebookRunState: extHostTypes.NotebookRunState,
NotebookCellStatusBarAlignment: extHostTypes.NotebookCellStatusBarAlignment, NotebookCellStatusBarAlignment: extHostTypes.NotebookCellStatusBarAlignment,
NotebookEditorRevealType: extHostTypes.NotebookEditorRevealType, NotebookEditorRevealType: extHostTypes.NotebookEditorRevealType,
NotebookCellOutputList: extHostTypes.NotebookCellOutputList,
NotebookCellOutput: extHostTypes.NotebookCellOutput, NotebookCellOutput: extHostTypes.NotebookCellOutput,
NotebookCellOutputItem: extHostTypes.NotebookCellOutputItem,
}; };
}; };
} }

View file

@ -55,13 +55,13 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
}); });
} }
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutputList | vscode.CellOutput)[]): void { replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[]): void {
this._throwIfFinalized(); this._throwIfFinalized();
this._collectedEdits.push({ this._collectedEdits.push({
editType: CellEditType.Output, editType: CellEditType.Output,
index, index,
outputs: outputs.map(output => { outputs: outputs.map(output => {
if (extHostTypes.NotebookCellOutputList.isNotebookCellOutputList(output)) { if (extHostTypes.NotebookCellOutput.isNotebookCellOutputList(output)) {
return addIdToOutput(NotebookCellOutputList.from(output)); return addIdToOutput(NotebookCellOutputList.from(output));
} else { } else {
return addIdToOutput(output); return addIdToOutput(output);

View file

@ -1296,7 +1296,7 @@ export namespace LogLevel {
} }
export namespace NotebookCellOutputList { export namespace NotebookCellOutputList {
export function from(output: types.NotebookCellOutputList): IDisplayOutput { export function from(output: types.NotebookCellOutput): IDisplayOutput {
let data: { [key: string]: unknown; } = {}; let data: { [key: string]: unknown; } = {};
let custom: { [key: string]: unknown; } = {}; let custom: { [key: string]: unknown; } = {};
@ -1318,7 +1318,7 @@ export namespace NotebookCellOutputList {
} }
export namespace NotebookCellOutput { export namespace NotebookCellOutput {
export function from(output: types.NotebookCellOutput): IDisplayOutput { export function from(output: types.NotebookCellOutputItem): IDisplayOutput {
return { return {
outputKind: CellOutputKind.Rich, outputKind: CellOutputKind.Rich,
data: { [output.mime]: output.value }, data: { [output.mime]: output.value },

View file

@ -2772,10 +2772,10 @@ export enum ColorThemeKind {
//#region Notebook //#region Notebook
export class NotebookCellOutput { export class NotebookCellOutputItem {
static isNotebookCellOutput(obj: unknown): obj is vscode.NotebookCellOutput { static isNotebookCellOutput(obj: unknown): obj is vscode.NotebookCellOutputItem {
return obj instanceof NotebookCellOutput; return obj instanceof NotebookCellOutputItem;
} }
constructor( constructor(
@ -2785,14 +2785,14 @@ export class NotebookCellOutput {
) { } ) { }
} }
export class NotebookCellOutputList { export class NotebookCellOutput {
static isNotebookCellOutputList(obj: unknown): obj is vscode.NotebookCellOutputList { static isNotebookCellOutputList(obj: unknown): obj is vscode.NotebookCellOutput {
return obj instanceof NotebookCellOutputList; return obj instanceof NotebookCellOutput;
} }
constructor( constructor(
readonly outputs: NotebookCellOutput[], readonly outputs: NotebookCellOutputItem[],
readonly metadata?: Record<string, string | number | boolean> readonly metadata?: Record<string, string | number | boolean>
) { } ) { }
} }