mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fixes with tests
This commit is contained in:
parent
31abc3784e
commit
7bbd66c2d2
|
@ -227,7 +227,7 @@ function convertStreamOutput(output: NotebookCellOutput): JupyterOutput {
|
|||
const outputs: string[] = [];
|
||||
output.items
|
||||
.filter((opit) => opit.mime === CellOutputMimeTypes.stderr || opit.mime === CellOutputMimeTypes.stdout)
|
||||
.map((opit) => convertOutputMimeToJupyterOutput(opit.mime, opit.data as Uint8Array) as string)
|
||||
.map((opit) => textDecoder.decode(opit.data))
|
||||
.forEach(value => {
|
||||
// Ensure each line is a seprate entry in an array (ending with \n).
|
||||
const lines = value.split('\n');
|
||||
|
@ -240,6 +240,11 @@ function convertStreamOutput(output: NotebookCellOutput): JupyterOutput {
|
|||
outputs.push(line);
|
||||
}
|
||||
});
|
||||
|
||||
for (let index = 0; index < (outputs.length - 1); index++) {
|
||||
outputs[index] = `${outputs[index]}\n`;
|
||||
}
|
||||
|
||||
// Skip last one if empty (it's the only one that could be length 0)
|
||||
if (outputs.length && outputs[outputs.length - 1].length === 0) {
|
||||
outputs.pop();
|
||||
|
|
|
@ -106,6 +106,48 @@ suite('ipynb serializer', () => {
|
|||
]
|
||||
);
|
||||
});
|
||||
test('Stream output and line endings', () => {
|
||||
validateCellOutputTranslation(
|
||||
[
|
||||
{
|
||||
output_type: 'stream',
|
||||
name: 'stdout',
|
||||
text: [
|
||||
'Line1\n',
|
||||
'\n',
|
||||
'Line3\n',
|
||||
'Line4'
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
new vscode.NotebookCellOutput([vscode.NotebookCellOutputItem.stdout('Line1\n\nLine3\nLine4')], {
|
||||
outputType: 'stream'
|
||||
})
|
||||
]
|
||||
);
|
||||
validateCellOutputTranslation(
|
||||
[
|
||||
{
|
||||
output_type: 'stream',
|
||||
name: 'stdout',
|
||||
text: [
|
||||
'Hello\n',
|
||||
'Hello\n',
|
||||
'Hello\n',
|
||||
'Hello\n',
|
||||
'Hello\n',
|
||||
'Hello\n'
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
new vscode.NotebookCellOutput([vscode.NotebookCellOutputItem.stdout('Hello\nHello\nHello\nHello\nHello\nHello\n')], {
|
||||
outputType: 'stream'
|
||||
})
|
||||
]
|
||||
);
|
||||
});
|
||||
test('Multi-line Stream output', () => {
|
||||
validateCellOutputTranslation(
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue