diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts index aa74492c55a..ceaeec219d8 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts @@ -351,7 +351,6 @@ suite('Notebook Document', function () { test('#117273, Add multiple outputs', async function () { - this.skip(); const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest'); const document = await vscode.notebook.openNotebookDocument(resource); @@ -372,26 +371,13 @@ suite('Notebook Document', function () { assert.deepStrictEqual(document.cells[0].outputs[0].outputs[0].metadata, { outputType: 'stream', streamName: 'stdout' }); const edit2 = new vscode.WorkspaceEdit(); - // All of the following edit operations fail. edit2.appendNotebookCellOutput(document.uri, 0, [ new vscode.NotebookCellOutput( [new vscode.NotebookCellOutputItem('hello', '1', { outputType: 'stream', streamName: 'stderr' })], { outputType: 'stream', streamName: 'stderr' } ) ]); - // edit2.replaceNotebookCellOutput(document.uri, 0, [ - // ...document.cells[0].outputs, - // new vscode.NotebookCellOutput([new vscode.NotebookCellOutputItem('hello', '1', { outputType: 'stream', streamName: 'stderr' })], { outputType: 'stream', streamName: 'stderr' }) - // ]); - // edit2.replaceNotebookCellOutput(document.uri, 0, [ - // ...document.cells[0].outputs, - // new vscode.NotebookCellOutput([new vscode.NotebookCellOutputItem('application/x.notebook.stream', '1', { outputType: 'stream', streamName: 'stderr' })], { outputType: 'stream', streamName: 'stderr' }) - // ]); - // This wasn't working, i had to revert to using `replaceNotebookCellOutput` (could be because we had two output in the cell). - // edit2.appendNotebookCellOutputItems(document.uri, 0, document.cells[0].outputs[1].id, [ - // new vscode.NotebookCellOutputItem('hello', 'Append to existing stderr when we have two outputs (one for stdout & one for stderr)', { outputType: 'stream', streamName: 'stderr' }) - // ]); - success = await vscode.workspace.applyEdit(edit); + success = await vscode.workspace.applyEdit(edit2); assert.ok(success); assert.strictEqual(document.cells[0].outputs.length, 2); diff --git a/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts b/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts index df4d6a86b6c..6caa4fd6624 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts @@ -351,4 +351,41 @@ suite('NotebookTextModel', () => { } ); }); + + + test('Updating appending/updating output in Notebooks does not work as expected #117273', function () { + withTestNotebook(instantiationService, blukEditService, undoRedoService, [ + ['var a = 1;', 'javascript', CellKind.Code, [], { editable: true }] + ], (_editor, _view, model) => { + + assert.strictEqual(model.cells.length, 1); + assert.strictEqual(model.cells[0].outputs.length, 0); + + const success1 = model.applyEdits( + model.versionId, + [{ + editType: CellEditType.Output, index: 0, outputs: [ + { outputId: 'out1', outputs: [{ mime: 'application/x.notebook.stream', value: 1 }] } + ], + append: false + }], true, undefined, () => undefined, undefined, false + ); + + assert.ok(success1); + assert.strictEqual(model.cells[0].outputs.length, 1); + + const success2 = model.applyEdits( + model.versionId, + [{ + editType: CellEditType.Output, index: 0, outputs: [ + { outputId: 'out2', outputs: [{ mime: 'application/x.notebook.stream', value: 1 }] } + ], + append: true + }], true, undefined, () => undefined, undefined, false + ); + + assert.ok(success2); + assert.strictEqual(model.cells[0].outputs.length, 2); + }); + }); });