Skip to content

Commit 050be7d

Browse files
committed
add test for using carraige return to replace previous text
1 parent 205ea5f commit 050be7d

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/vs/workbench/contrib/notebook/test/browser/notebookTextModel.test.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ suite('NotebookTextModel', () => {
436436
);
437437
});
438438

439-
test('appending streaming outputs with compression', async function () {
439+
test('appending streaming outputs with move cursor compression', async function () {
440440

441441
await withTestNotebook(
442442
[
@@ -478,6 +478,48 @@ suite('NotebookTextModel', () => {
478478
);
479479
});
480480

481+
test('appending streaming outputs with carraige return compression', async function () {
482+
483+
await withTestNotebook(
484+
[
485+
['var a = 1;', 'javascript', CellKind.Code, [], {}],
486+
],
487+
(editor) => {
488+
const textModel = editor.textModel;
489+
490+
textModel.applyEdits([
491+
{
492+
index: 0,
493+
editType: CellEditType.Output,
494+
append: true,
495+
outputs: [{
496+
outputId: 'append1',
497+
outputs: [
498+
{ mime: stdOutMime, data: valueBytesFromString('append 1') },
499+
{ mime: stdOutMime, data: valueBytesFromString('\nappend 1') }]
500+
}]
501+
}], true, undefined, () => undefined, undefined, true);
502+
const [output] = textModel.cells[0].outputs;
503+
assert.strictEqual(output.versionId, 0, 'initial output version should be 0');
504+
505+
textModel.applyEdits([
506+
{
507+
editType: CellEditType.OutputItems,
508+
append: true,
509+
outputId: 'append1',
510+
items: [{
511+
mime: stdOutMime, data: valueBytesFromString('\rappend 2')
512+
}]
513+
}], true, undefined, () => undefined, undefined, true);
514+
assert.strictEqual(output.versionId, 1, 'version should bump per append');
515+
516+
assert.strictEqual(output.outputs[0].data.toString(), 'append 1\nappend 2');
517+
assert.strictEqual(output.appendedSinceVersion(0, stdOutMime), undefined,
518+
'compressing outputs should clear out previous versioned output buffers');
519+
}
520+
);
521+
});
522+
481523
test('appending multiple different mime streaming outputs', async function () {
482524
await withTestNotebook(
483525
[

0 commit comments

Comments
 (0)