remove legacy typings.
This commit is contained in:
parent
3edc9925e0
commit
0544c1d391
9 changed files with 196 additions and 284 deletions
|
@ -297,7 +297,7 @@ suite('Notebook API tests', () => {
|
|||
document: vscode.window.activeNotebookEditor!.document,
|
||||
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs2.length, 1);
|
||||
|
||||
const cellOutputClear = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
|
@ -306,7 +306,7 @@ suite('Notebook API tests', () => {
|
|||
document: vscode.window.activeNotebookEditor!.document,
|
||||
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs2.length, 0);
|
||||
|
||||
// const cellChangeLanguage = getEventOncePromise<vscode.NotebookCellLanguageChangeEvent>(vscode.notebook.onDidChangeCellLanguage);
|
||||
// await vscode.commands.executeCommand('notebook.cell.changeToMarkdown');
|
||||
|
@ -447,15 +447,16 @@ suite('Notebook API tests', () => {
|
|||
const document = vscode.window.activeNotebookEditor?.document!;
|
||||
assert.strictEqual(document.isDirty, true);
|
||||
assert.strictEqual(document.cells.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs2.length, 1);
|
||||
|
||||
// consuming is OLD api (for now)
|
||||
const [output] = document.cells[0].outputs;
|
||||
const [output] = document.cells[0].outputs2;
|
||||
|
||||
assert.strictEqual(output.outputKind, vscode.CellOutputKind.Rich);
|
||||
assert.strictEqual((<vscode.CellDisplayOutput>output).data['application/foo'], 'bar');
|
||||
assert.deepStrictEqual((<vscode.CellDisplayOutput>output).data['application/json'], { data: true });
|
||||
assert.deepStrictEqual((<vscode.CellDisplayOutput>output).metadata, { custom: { 'application/json': { metadata: true } } });
|
||||
assert.strictEqual(output.outputs.length, 2);
|
||||
assert.strictEqual(output.outputs[0].mime, 'application/foo');
|
||||
assert.strictEqual(output.outputs[0].value, 'bar');
|
||||
assert.strictEqual(output.outputs[1].mime, 'application/json');
|
||||
assert.deepStrictEqual(output.outputs[1].value, { data: true });
|
||||
|
||||
await saveAllFilesAndCloseAll(undefined);
|
||||
});
|
||||
|
@ -466,14 +467,18 @@ suite('Notebook API tests', () => {
|
|||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
await vscode.window.activeNotebookEditor!.edit(editBuilder => {
|
||||
editBuilder.replaceCellOutput(0, [{ outputKind: vscode.CellOutputKind.Rich, data: { foo: 'bar' } }]);
|
||||
editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('foo', 'bar')
|
||||
])]);
|
||||
});
|
||||
|
||||
const document = vscode.window.activeNotebookEditor?.document!;
|
||||
assert.strictEqual(document.isDirty, true);
|
||||
assert.strictEqual(document.cells.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs[0].outputKind, vscode.CellOutputKind.Rich);
|
||||
assert.strictEqual(document.cells[0].outputs2.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs2[0].outputs.length, 1);
|
||||
assert.strictEqual(document.cells[0].outputs2[0].outputs[0].mime, 'foo');
|
||||
assert.strictEqual(document.cells[0].outputs2[0].outputs[0].value, 'bar');
|
||||
|
||||
await saveAllFilesAndCloseAll(undefined);
|
||||
});
|
||||
|
@ -485,15 +490,20 @@ suite('Notebook API tests', () => {
|
|||
|
||||
const outputChangeEvent = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.window.activeNotebookEditor!.edit(editBuilder => {
|
||||
editBuilder.replaceCellOutput(0, [{ outputKind: vscode.CellOutputKind.Rich, data: { foo: 'bar' } }]);
|
||||
editBuilder.replaceCellOutput(0, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('foo', 'bar')
|
||||
])]);
|
||||
});
|
||||
|
||||
const value = await outputChangeEvent;
|
||||
assert.strictEqual(value.document === vscode.window.activeNotebookEditor?.document, true);
|
||||
assert.strictEqual(value.document.isDirty, true);
|
||||
assert.strictEqual(value.cells.length, 1);
|
||||
assert.strictEqual(value.cells[0].outputs.length, 1);
|
||||
assert.strictEqual(value.cells[0].outputs[0].outputKind, vscode.CellOutputKind.Rich);
|
||||
assert.strictEqual(value.document.cells.length, 1);
|
||||
assert.strictEqual(value.document.cells[0].outputs2.length, 1);
|
||||
assert.strictEqual(value.document.cells[0].outputs2[0].outputs.length, 1);
|
||||
assert.strictEqual(value.document.cells[0].outputs2[0].outputs[0].mime, 'foo');
|
||||
assert.strictEqual(value.document.cells[0].outputs2[0].outputs[0].value, 'bar');
|
||||
|
||||
await saveAllFilesAndCloseAll(undefined);
|
||||
});
|
||||
|
@ -906,21 +916,21 @@ suite('notebook workflow', () => {
|
|||
|
||||
await vscode.commands.executeCommand('notebook.focusTop');
|
||||
const cell = editor.document.cells[0];
|
||||
assert.strictEqual(cell.outputs.length, 0);
|
||||
assert.strictEqual(cell.outputs2.length, 0);
|
||||
|
||||
let metadataChangeEvent = getEventOncePromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
|
||||
await updateCellMetadata(resource, cell, { ...cell.metadata, runnable: false });
|
||||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
assert.strictEqual(cell.outputs2.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
|
||||
metadataChangeEvent = getEventOncePromise<vscode.NotebookCellMetadataChangeEvent>(vscode.notebook.onDidChangeCellMetadata);
|
||||
await updateCellMetadata(resource, cell, { ...cell.metadata, runnable: true });
|
||||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
@ -934,7 +944,7 @@ suite('notebook workflow', () => {
|
|||
const editor = vscode.window.activeNotebookEditor!;
|
||||
|
||||
const cell = editor.document.cells[0];
|
||||
assert.strictEqual(cell.outputs.length, 0);
|
||||
assert.strictEqual(cell.outputs2.length, 0);
|
||||
|
||||
await withEvent(vscode.notebook.onDidChangeNotebookDocumentMetadata, async event => {
|
||||
updateNotebookMetadata(editor.document.uri, { ...editor.document.metadata, runnable: false });
|
||||
|
@ -942,7 +952,7 @@ suite('notebook workflow', () => {
|
|||
});
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
assert.strictEqual(cell.outputs2.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
|
||||
await withEvent(vscode.notebook.onDidChangeNotebookDocumentMetadata, async event => {
|
||||
updateNotebookMetadata(editor.document.uri, { ...editor.document.metadata, runnable: true });
|
||||
|
@ -952,7 +962,7 @@ suite('notebook workflow', () => {
|
|||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
});
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
|
@ -970,7 +980,7 @@ suite('notebook workflow', () => {
|
|||
const cell = editor.document.cells[0];
|
||||
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
assert.strictEqual(cell.outputs2.length, 0, 'should not execute'); // not runnable, didn't work
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
|
@ -992,13 +1002,13 @@ suite('notebook workflow', () => {
|
|||
await withEvent(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
});
|
||||
|
||||
await withEvent(vscode.notebook.onDidChangeCellOutputs, async event => {
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should clear');
|
||||
assert.strictEqual(cell.outputs2.length, 0, 'should clear');
|
||||
});
|
||||
|
||||
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
|
||||
|
@ -1007,7 +1017,7 @@ suite('notebook workflow', () => {
|
|||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.cell.execute', { start: 0, end: 1 }, resource);
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
|
||||
});
|
||||
|
||||
|
@ -1033,13 +1043,13 @@ suite('notebook workflow', () => {
|
|||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute');
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
});
|
||||
|
||||
const clearChangeEvent = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.clearOutputs');
|
||||
await clearChangeEvent;
|
||||
assert.strictEqual(cell.outputs.length, 0, 'should clear');
|
||||
assert.strictEqual(cell.outputs2.length, 0, 'should clear');
|
||||
|
||||
const secondResource = await createRandomFile('', undefined, 'second', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', secondResource, 'notebookCoreTest');
|
||||
|
@ -1047,7 +1057,7 @@ suite('notebook workflow', () => {
|
|||
await withEvent<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs, async (event) => {
|
||||
await vscode.commands.executeCommand('notebook.execute', resource);
|
||||
await event;
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath);
|
||||
});
|
||||
|
||||
|
@ -1070,21 +1080,22 @@ suite('notebook workflow', () => {
|
|||
await metadataChangeEvent;
|
||||
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.deepStrictEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
|
||||
'text/plain': [
|
||||
'my output'
|
||||
]
|
||||
});
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs2[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(cell.outputs2[0].outputs[0].value, [
|
||||
'my output'
|
||||
]);
|
||||
|
||||
await vscode.commands.executeCommand('notebook.selectKernel', { extension: 'vscode.vscode-notebook-tests', id: 'secondaryKernel' });
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.deepStrictEqual((cell.outputs[0] as vscode.CellDisplayOutput).data, {
|
||||
'text/plain': [
|
||||
'my second output'
|
||||
]
|
||||
});
|
||||
assert.strictEqual(cell.outputs2.length, 1, 'should execute'); // runnable, it worked
|
||||
assert.strictEqual(cell.outputs2[0].outputs.length, 1);
|
||||
assert.strictEqual(cell.outputs2[0].outputs[0].mime, 'text/plain');
|
||||
assert.deepStrictEqual(cell.outputs2[0].outputs[0].value, [
|
||||
'my second output'
|
||||
]);
|
||||
|
||||
await vscode.commands.executeCommand('workbench.action.files.save');
|
||||
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
|
||||
});
|
||||
|
@ -1168,68 +1179,68 @@ suite('notebook undo redo', () => {
|
|||
await saveFileAndCloseAll(resource);
|
||||
});
|
||||
|
||||
test.skip('execute and then undo redo', async function () {
|
||||
assertInitalState();
|
||||
const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
// test.skip('execute and then undo redo', async function () {
|
||||
// assertInitalState();
|
||||
// const resource = await createRandomFile('', undefined, 'first', '.vsctestnb');
|
||||
// await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest');
|
||||
|
||||
const cellsChangeEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
const cellChangeEventRet = await cellsChangeEvent;
|
||||
assert.strictEqual(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
|
||||
assert.strictEqual(cellChangeEventRet.changes.length, 1);
|
||||
assert.deepStrictEqual(cellChangeEventRet.changes[0], {
|
||||
start: 1,
|
||||
deletedCount: 0,
|
||||
deletedItems: [],
|
||||
items: [
|
||||
vscode.window.activeNotebookEditor!.document.cells[1]
|
||||
]
|
||||
});
|
||||
// const cellsChangeEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
// await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow');
|
||||
// const cellChangeEventRet = await cellsChangeEvent;
|
||||
// assert.strictEqual(cellChangeEventRet.document, vscode.window.activeNotebookEditor?.document);
|
||||
// assert.strictEqual(cellChangeEventRet.changes.length, 1);
|
||||
// assert.deepStrictEqual(cellChangeEventRet.changes[0], {
|
||||
// start: 1,
|
||||
// deletedCount: 0,
|
||||
// deletedItems: [],
|
||||
// items: [
|
||||
// vscode.window.activeNotebookEditor!.document.cells[1]
|
||||
// ]
|
||||
// });
|
||||
|
||||
const secondCell = vscode.window.activeNotebookEditor!.document.cells[1];
|
||||
// const secondCell = vscode.window.activeNotebookEditor!.document.cells[1];
|
||||
|
||||
const moveCellEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
await vscode.commands.executeCommand('notebook.cell.moveUp');
|
||||
const moveCellEventRet = await moveCellEvent;
|
||||
assert.deepStrictEqual(moveCellEventRet, {
|
||||
document: vscode.window.activeNotebookEditor!.document,
|
||||
changes: [
|
||||
{
|
||||
start: 1,
|
||||
deletedCount: 1,
|
||||
deletedItems: [secondCell],
|
||||
items: []
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
deletedCount: 0,
|
||||
deletedItems: [],
|
||||
items: [vscode.window.activeNotebookEditor?.document.cells[0]]
|
||||
}
|
||||
]
|
||||
});
|
||||
// const moveCellEvent = getEventOncePromise<vscode.NotebookCellsChangeEvent>(vscode.notebook.onDidChangeNotebookCells);
|
||||
// await vscode.commands.executeCommand('notebook.cell.moveUp');
|
||||
// const moveCellEventRet = await moveCellEvent;
|
||||
// assert.deepStrictEqual(moveCellEventRet, {
|
||||
// document: vscode.window.activeNotebookEditor!.document,
|
||||
// changes: [
|
||||
// {
|
||||
// start: 1,
|
||||
// deletedCount: 1,
|
||||
// deletedItems: [secondCell],
|
||||
// items: []
|
||||
// },
|
||||
// {
|
||||
// start: 0,
|
||||
// deletedCount: 0,
|
||||
// deletedItems: [],
|
||||
// items: [vscode.window.activeNotebookEditor?.document.cells[0]]
|
||||
// }
|
||||
// ]
|
||||
// });
|
||||
|
||||
const cellOutputChange = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
const cellOutputsAddedRet = await cellOutputChange;
|
||||
assert.deepStrictEqual(cellOutputsAddedRet, {
|
||||
document: vscode.window.activeNotebookEditor!.document,
|
||||
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
|
||||
// const cellOutputChange = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
// await vscode.commands.executeCommand('notebook.cell.execute');
|
||||
// const cellOutputsAddedRet = await cellOutputChange;
|
||||
// assert.deepStrictEqual(cellOutputsAddedRet, {
|
||||
// document: vscode.window.activeNotebookEditor!.document,
|
||||
// cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
// });
|
||||
// assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 1);
|
||||
|
||||
const cellOutputClear = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
await vscode.commands.executeCommand('undo');
|
||||
const cellOutputsCleardRet = await cellOutputClear;
|
||||
assert.deepStrictEqual(cellOutputsCleardRet, {
|
||||
document: vscode.window.activeNotebookEditor!.document,
|
||||
cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
});
|
||||
assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
|
||||
// const cellOutputClear = getEventOncePromise<vscode.NotebookCellOutputsChangeEvent>(vscode.notebook.onDidChangeCellOutputs);
|
||||
// await vscode.commands.executeCommand('undo');
|
||||
// const cellOutputsCleardRet = await cellOutputClear;
|
||||
// assert.deepStrictEqual(cellOutputsCleardRet, {
|
||||
// document: vscode.window.activeNotebookEditor!.document,
|
||||
// cells: [vscode.window.activeNotebookEditor!.document.cells[0]]
|
||||
// });
|
||||
// assert.strictEqual(cellOutputsAddedRet.cells[0].outputs.length, 0);
|
||||
|
||||
await saveFileAndCloseAll(resource);
|
||||
});
|
||||
// await saveFileAndCloseAll(resource);
|
||||
// });
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -72,12 +72,9 @@ export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
|||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
for (let i = 0; i < _document.cells.length; i++) {
|
||||
edit.replaceNotebookCellOutput(_document.uri, i, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/html': ['test output']
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(_document.uri, i, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/html', ['test output'], undefined)
|
||||
])]);
|
||||
}
|
||||
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
|
@ -89,12 +86,9 @@ export function smokeTestActivate(context: vscode.ExtensionContext): any {
|
|||
}
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(_document.uri, _cell.index, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/html': ['test output']
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(_document.uri, _cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/html', ['test output'], undefined)
|
||||
])]);
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
return;
|
||||
},
|
||||
|
|
|
@ -62,12 +62,10 @@ export function activate(context: vscode.ExtensionContext): any {
|
|||
isPreferred: true,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(_document.uri, 0, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my output']
|
||||
}
|
||||
}]);
|
||||
|
||||
edit.replaceNotebookCellOutput(_document.uri, 0, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/plain', ['my output'], undefined)
|
||||
])]);
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
cancelAllCellsExecution: async (_document: vscode.NotebookDocument) => { },
|
||||
|
@ -78,24 +76,18 @@ export function activate(context: vscode.ExtensionContext): any {
|
|||
|
||||
if (document.uri.path.endsWith('customRenderer.vsctestnb')) {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/custom': 'test'
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/custom', ['test'], undefined)
|
||||
])]);
|
||||
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
}
|
||||
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
// const previousOutputs = cell.outputs;
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my output']
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/plain', ['my output'], undefined)
|
||||
])]);
|
||||
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
|
@ -108,12 +100,10 @@ export function activate(context: vscode.ExtensionContext): any {
|
|||
isPreferred: false,
|
||||
executeAllCells: async (_document: vscode.NotebookDocument) => {
|
||||
const edit = new vscode.WorkspaceEdit();
|
||||
edit.replaceNotebookCellOutput(_document.uri, 0, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my second output']
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(_document.uri, 0, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/plain', ['my second output'], undefined)
|
||||
])]);
|
||||
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
},
|
||||
cancelAllCellsExecution: async (_document: vscode.NotebookDocument) => { },
|
||||
|
@ -125,19 +115,13 @@ export function activate(context: vscode.ExtensionContext): any {
|
|||
const edit = new vscode.WorkspaceEdit();
|
||||
|
||||
if (document.uri.path.endsWith('customRenderer.vsctestnb')) {
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/custom': 'test 2'
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/custom', ['test 2'], undefined)
|
||||
])]);
|
||||
} else {
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [{
|
||||
outputKind: vscode.CellOutputKind.Rich,
|
||||
data: {
|
||||
'text/plain': ['my second output']
|
||||
}
|
||||
}]);
|
||||
edit.replaceNotebookCellOutput(document.uri, cell.index, [new vscode.NotebookCellOutput([
|
||||
new vscode.NotebookCellOutputItem('text/plain', ['my second output'], undefined)
|
||||
])]);
|
||||
}
|
||||
|
||||
return vscode.workspace.applyEdit(edit);
|
||||
|
|
|
@ -45,23 +45,23 @@ if "%INTEGRATION_TEST_ELECTRON_PATH%"=="" (
|
|||
|
||||
:: Tests in the extension host
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\singlefolder-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testWorkspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\singlefolder-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\workspace-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-api-tests\testworkspace.code-workspace --enable-proposed-api=vscode.vscode-api-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-api-tests --extensionTestsPath=%~dp0\..\extensions\vscode-api-tests\out\workspace-tests --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-colorize-tests\test --extensionDevelopmentPath=%~dp0\..\extensions\vscode-colorize-tests --extensionTestsPath=%~dp0\..\extensions\vscode-colorize-tests\out --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test\unit --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\typescript-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\typescript-language-features --extensionTestsPath=%~dp0\..\extensions\typescript-language-features\out\test\unit --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\markdown-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\markdown-language-features --extensionTestsPath=%~dp0\..\extensions\markdown-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\markdown-language-features\test-workspace --extensionDevelopmentPath=%~dp0\..\extensions\markdown-language-features --extensionTestsPath=%~dp0\..\extensions\markdown-language-features\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
@REM call "%INTEGRATION_TEST_ELECTRON_PATH%" $%~dp0\..\extensions\emmet\out\test\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% .
|
||||
@REM if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" $%~dp0\..\extensions\emmet\out\test\test-fixtures --extensionDevelopmentPath=%~dp0\..\extensions\emmet --extensionTestsPath=%~dp0\..\extensions\emmet\out\test --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR% .
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
||||
call "%INTEGRATION_TEST_ELECTRON_PATH%" %~dp0\..\extensions\vscode-notebook-tests\test --enable-proposed-api=vscode.vscode-notebook-tests --extensionDevelopmentPath=%~dp0\..\extensions\vscode-notebook-tests --extensionTestsPath=%~dp0\..\extensions\vscode-notebook-tests\out --disable-telemetry --crash-reporter-directory=%VSCODECRASHDIR% --no-cached-data --disable-updates --disable-extensions --user-data-dir=%VSCODEUSERDATADIR%
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
|
77
src/vs/vscode.proposed.d.ts
vendored
77
src/vs/vscode.proposed.d.ts
vendored
|
@ -1081,7 +1081,6 @@ declare module 'vscode' {
|
|||
readonly cellKind: CellKind;
|
||||
readonly document: TextDocument;
|
||||
readonly language: string;
|
||||
readonly outputs: CellOutput[];
|
||||
readonly outputs2: readonly NotebookCellOutput[];
|
||||
readonly metadata: NotebookCellMetadata;
|
||||
/** @deprecated use WorkspaceEdit.replaceCellOutput */
|
||||
|
@ -1311,7 +1310,7 @@ declare module 'vscode' {
|
|||
readonly source: string;
|
||||
readonly language: string;
|
||||
// todo@API maybe use a separate data type?
|
||||
readonly outputs: (CellOutput | NotebookCellOutput)[];
|
||||
readonly outputs: NotebookCellOutput[];
|
||||
readonly metadata: NotebookCellMetadata | undefined;
|
||||
}
|
||||
|
||||
|
@ -1401,72 +1400,6 @@ declare module 'vscode' {
|
|||
|
||||
//#region https://github.com/microsoft/vscode/issues/106744, NotebookCellOutput
|
||||
|
||||
/** @deprecated */
|
||||
export enum CellOutputKind {
|
||||
Text = 1,
|
||||
Error = 2,
|
||||
Rich = 3
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface CellStreamOutput {
|
||||
outputKind: CellOutputKind.Text;
|
||||
text: string;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface CellErrorOutput {
|
||||
outputKind: CellOutputKind.Error;
|
||||
/**
|
||||
* Exception Name
|
||||
*/
|
||||
ename: string;
|
||||
/**
|
||||
* Exception Value
|
||||
*/
|
||||
evalue: string;
|
||||
/**
|
||||
* Exception call stack
|
||||
*/
|
||||
traceback: string[];
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface NotebookCellOutputMetadata {
|
||||
/**
|
||||
* Additional attributes of a cell metadata.
|
||||
*/
|
||||
custom?: { [key: string]: any; };
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface CellDisplayOutput {
|
||||
outputKind: CellOutputKind.Rich;
|
||||
/**
|
||||
* { mime_type: value }
|
||||
*
|
||||
* Example:
|
||||
* ```json
|
||||
* {
|
||||
* "outputKind": vscode.CellOutputKind.Rich,
|
||||
* "data": {
|
||||
* "text/html": [
|
||||
* "<h1>Hello</h1>"
|
||||
* ],
|
||||
* "text/plain": [
|
||||
* "<IPython.lib.display.IFrame at 0x11dee3e80>"
|
||||
* ]
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
data: { [key: string]: any; };
|
||||
|
||||
readonly metadata?: NotebookCellOutputMetadata;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput;
|
||||
|
||||
// code specific mime types
|
||||
// application/x.notebook.error-traceback
|
||||
// application/x.notebook.stream
|
||||
|
@ -1503,21 +1436,19 @@ declare module 'vscode' {
|
|||
replaceNotebookCells(uri: Uri, start: number, end: number, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: NotebookCellMetadata, metadata?: WorkspaceEditEntryMetadata): void;
|
||||
|
||||
replaceNotebookCellOutput(uri: Uri, index: number, outputs: (NotebookCellOutput | CellOutput)[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
appendNotebookCellOutput(uri: Uri, index: number, outputs: (NotebookCellOutput | CellOutput)[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
replaceNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
appendNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
|
||||
// TODO@api
|
||||
// https://jupyter-protocol.readthedocs.io/en/latest/messaging.html#update-display-data
|
||||
replaceNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
appendNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
// replaceNotebookCellOutput(uri: Uri, index: number, outputId:string, outputs: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
// appendNotebookCellOutput(uri: Uri, index: number, outputId:string, outputs: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
|
||||
}
|
||||
|
||||
export interface NotebookEditorEdit {
|
||||
replaceMetadata(value: NotebookDocumentMetadata): void;
|
||||
replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
|
||||
replaceCellOutput(index: number, outputs: (NotebookCellOutput | CellOutput)[]): void;
|
||||
replaceCellOutput(index: number, outputs: NotebookCellOutput[]): void;
|
||||
replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import { ISplice } from 'vs/base/common/sequence';
|
|||
import { URI } from 'vs/base/common/uri';
|
||||
import { CellKind, INotebookDocumentPropertiesChangeData, MainThreadNotebookShape } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { ExtHostDocumentsAndEditors, IExtHostModelAddedData } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { NotebookCellOutput } from 'vs/workbench/api/common/extHostTypes';
|
||||
import * as extHostTypeConverters from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { IMainCellDto, IOutputDto, NotebookCellMetadata, NotebookCellsChangedEventDto, NotebookCellsChangeType, NotebookCellsSplice2, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import * as vscode from 'vscode';
|
||||
|
@ -92,10 +91,10 @@ export class ExtHostCell extends Disposable {
|
|||
cellKind: this._cellData.cellKind,
|
||||
document: data.document,
|
||||
get language() { return data!.document.languageId; },
|
||||
get outputs() {
|
||||
return that._outputs.map(output => NotebookCellOutput._toOld(output));
|
||||
},
|
||||
set outputs(_value) { throw new Error('Use WorkspaceEdit to update cell outputs.'); },
|
||||
// get outputs() {
|
||||
// return that._outputs.map(output => NotebookCellOutput._toOld(output));
|
||||
// },
|
||||
// set outputs(_value) { throw new Error('Use WorkspaceEdit to update cell outputs.'); },
|
||||
get outputs2() { return that._outputs.map(extHostTypeConverters.NotebookCellOutput.to); },
|
||||
set outputs2(_value) { throw new Error('Use WorkspaceEdit to update cell outputs.'); },
|
||||
get metadata() { return that._metadata; },
|
||||
|
|
|
@ -60,15 +60,12 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit {
|
|||
});
|
||||
}
|
||||
|
||||
replaceCellOutput(index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[]): void {
|
||||
replaceCellOutput(index: number, outputs: vscode.NotebookCellOutput[]): void {
|
||||
this._throwIfFinalized();
|
||||
this._collectedEdits.push({
|
||||
editType: CellEditType.Output,
|
||||
index,
|
||||
outputs: outputs.map(output => {
|
||||
if (!extHostTypes.NotebookCellOutput.isNotebookCellOutput(output)) {
|
||||
output = extHostTypes.NotebookCellOutput._fromOld(output);
|
||||
}
|
||||
return extHostConverter.NotebookCellOutput.from(output);
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1342,7 +1342,7 @@ export namespace NotebookCellData {
|
|||
} if (first instanceof types.NotebookCellOutput) {
|
||||
outputs = (<vscode.NotebookCellOutput[]>data.outputs).map(NotebookCellOutput.from);
|
||||
} else {
|
||||
outputs = (<vscode.CellOutput[]>data.outputs).map(o => NotebookCellOutput.from(types.NotebookCellOutput._fromOld(o)));
|
||||
outputs = [];
|
||||
}
|
||||
return {
|
||||
cellKind: data.cellKind,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { CellEditType, ICellEditOperation, IOutputDto, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellEditType, ICellEditOperation, notebookDocumentMetadataDefaults } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
function es5ClassCompat(target: Function): any {
|
||||
|
@ -682,11 +682,11 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
|||
}
|
||||
}
|
||||
|
||||
replaceNotebookCellOutput(uri: URI, index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[], metadata?: vscode.WorkspaceEditEntryMetadata): void {
|
||||
replaceNotebookCellOutput(uri: URI, index: number, outputs: vscode.NotebookCellOutput[], metadata?: vscode.WorkspaceEditEntryMetadata): void {
|
||||
this._editNotebookCellOutput(uri, index, false, outputs, metadata);
|
||||
}
|
||||
|
||||
appendNotebookCellOutput(uri: URI, index: number, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[], metadata?: vscode.WorkspaceEditEntryMetadata): void {
|
||||
appendNotebookCellOutput(uri: URI, index: number, outputs: vscode.NotebookCellOutput[], metadata?: vscode.WorkspaceEditEntryMetadata): void {
|
||||
this._editNotebookCellOutput(uri, index, true, outputs, metadata);
|
||||
}
|
||||
|
||||
|
@ -702,15 +702,15 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
|||
this._edits.push({ _type: FileEditType.CellOutputItem, metadata, uri, index, outputId: id, append, newOutputItems: items });
|
||||
}
|
||||
|
||||
private _editNotebookCellOutput(uri: URI, index: number, append: boolean, outputs: (vscode.NotebookCellOutput | vscode.CellOutput)[], metadata: vscode.WorkspaceEditEntryMetadata | undefined): void {
|
||||
let newOutputs: NotebookCellOutput[];
|
||||
private _editNotebookCellOutput(uri: URI, index: number, append: boolean, outputs: vscode.NotebookCellOutput[], metadata: vscode.WorkspaceEditEntryMetadata | undefined): void {
|
||||
let newOutputs: NotebookCellOutput[] = [];
|
||||
const [first] = outputs;
|
||||
if (!first) {
|
||||
newOutputs = [];
|
||||
} else if (first instanceof NotebookCellOutput) {
|
||||
newOutputs = (<NotebookCellOutput[]>outputs);
|
||||
} else {
|
||||
newOutputs = (<vscode.CellOutput[]>outputs).map(o => NotebookCellOutput._fromOld(o));
|
||||
// newOutputs = (<vscode.CellOutput[]>outputs).map(o => NotebookCellOutput._fromOld(o));
|
||||
}
|
||||
this._edits.push({ _type: FileEditType.CellOutput, metadata, uri, index, append, newOutputs, newMetadata: undefined });
|
||||
}
|
||||
|
@ -2866,47 +2866,43 @@ export class NotebookCellOutputItem {
|
|||
|
||||
export class NotebookCellOutput {
|
||||
|
||||
static _toOld(output: IOutputDto): vscode.CellOutput {
|
||||
if (output.data['application/x.notebook.stream']) {
|
||||
return {
|
||||
outputKind: CellOutputKind.Text,
|
||||
text: output.data['application/x.notebook.stream'] as string
|
||||
};
|
||||
} else if (output.data['application/x.notebook.error-traceback']) {
|
||||
return {
|
||||
outputKind: CellOutputKind.Error,
|
||||
ename: (output.data['application/x.notebook.error-traceback'] as any)['ename'],
|
||||
evalue: (output.data['application/x.notebook.error-traceback'] as any)['evalue'],
|
||||
traceback: (output.data['application/x.notebook.error-traceback'] as any)['traceback'],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
outputKind: CellOutputKind.Rich,
|
||||
data: output.data,
|
||||
metadata: output.metadata
|
||||
};
|
||||
}
|
||||
}
|
||||
// static _toOld(output: IOutputDto): vscode.CellOutput {
|
||||
// if (output.data['application/x.notebook.stream']) {
|
||||
// return {
|
||||
// outputKind: CellOutputKind.Text,
|
||||
// text: output.data['application/x.notebook.stream'] as string
|
||||
// };
|
||||
// } else if (output.data['application/x.notebook.error-traceback']) {
|
||||
// return {
|
||||
// outputKind: CellOutputKind.Error,
|
||||
// ename: (output.data['application/x.notebook.error-traceback'] as any)['ename'],
|
||||
// evalue: (output.data['application/x.notebook.error-traceback'] as any)['evalue'],
|
||||
// traceback: (output.data['application/x.notebook.error-traceback'] as any)['traceback'],
|
||||
// };
|
||||
// } else {
|
||||
// return {
|
||||
// outputKind: CellOutputKind.Rich,
|
||||
// data: output.data,
|
||||
// metadata: output.metadata
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
static _fromOld(output: vscode.CellOutput, id?: string): NotebookCellOutput {
|
||||
switch (output.outputKind) {
|
||||
case CellOutputKind.Error:
|
||||
return new NotebookCellOutput([new NotebookCellOutputItem('application/x.notebook.error-traceback', output)]);
|
||||
case CellOutputKind.Text:
|
||||
return new NotebookCellOutput([new NotebookCellOutputItem('application/x.notebook.stream', output.text)]);
|
||||
case CellOutputKind.Rich:
|
||||
const items: NotebookCellOutputItem[] = [];
|
||||
for (const key in output.data) {
|
||||
items.push(new NotebookCellOutputItem(key, output.data[key], output.metadata?.custom ? output.metadata?.custom[key] : undefined));
|
||||
}
|
||||
return new NotebookCellOutput(items, id);
|
||||
}
|
||||
throw new Error('invalid outputKind');
|
||||
}
|
||||
|
||||
static isNotebookCellOutput(obj: unknown): obj is vscode.NotebookCellOutput {
|
||||
return obj instanceof NotebookCellOutput;
|
||||
}
|
||||
// static _fromOld(output: vscode.CellOutput, id?: string): NotebookCellOutput {
|
||||
// switch (output.outputKind) {
|
||||
// case CellOutputKind.Error:
|
||||
// return new NotebookCellOutput([new NotebookCellOutputItem('application/x.notebook.error-traceback', output)]);
|
||||
// case CellOutputKind.Text:
|
||||
// return new NotebookCellOutput([new NotebookCellOutputItem('application/x.notebook.stream', output.text)]);
|
||||
// case CellOutputKind.Rich:
|
||||
// const items: NotebookCellOutputItem[] = [];
|
||||
// for (const key in output.data) {
|
||||
// items.push(new NotebookCellOutputItem(key, output.data[key], output.metadata?.custom ? output.metadata?.custom[key] : undefined));
|
||||
// }
|
||||
// return new NotebookCellOutput(items, id);
|
||||
// }
|
||||
// throw new Error('invalid outputKind');
|
||||
// }
|
||||
|
||||
constructor(readonly outputs: NotebookCellOutputItem[], readonly id: string = generateUuid()) { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue