@@ -11,7 +11,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language';
11
11
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock' ;
12
12
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo' ;
13
13
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel' ;
14
- import { CellEditType , CellKind , ICellEditOperation , NotebookTextModelChangedEvent , NotebookTextModelWillAddRemoveEvent , SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
14
+ import { CellEditType , CellKind , ICellEditOperation , MOVE_CURSOR_1_LINE_COMMAND , NotebookTextModelChangedEvent , NotebookTextModelWillAddRemoveEvent , SelectionStateType } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
15
15
import { setupInstantiationService , TestCell , valueBytesFromString , withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor' ;
16
16
17
17
suite ( 'NotebookTextModel' , ( ) => {
@@ -436,6 +436,48 @@ suite('NotebookTextModel', () => {
436
436
) ;
437
437
} ) ;
438
438
439
+ test ( 'appending streaming outputs with compression' , async function ( ) {
440
+
441
+ await withTestNotebook (
442
+ [
443
+ [ 'var a = 1;' , 'javascript' , CellKind . Code , [ ] , { } ] ,
444
+ ] ,
445
+ ( editor ) => {
446
+ const textModel = editor . textModel ;
447
+
448
+ textModel . applyEdits ( [
449
+ {
450
+ index : 0 ,
451
+ editType : CellEditType . Output ,
452
+ append : true ,
453
+ outputs : [ {
454
+ outputId : 'append1' ,
455
+ outputs : [
456
+ { mime : stdOutMime , data : valueBytesFromString ( 'append 1' ) } ,
457
+ { mime : stdOutMime , data : valueBytesFromString ( '\nappend 1' ) } ]
458
+ } ]
459
+ } ] , true , undefined , ( ) => undefined , undefined , true ) ;
460
+ const [ output ] = textModel . cells [ 0 ] . outputs ;
461
+ assert . strictEqual ( output . versionId , 0 , 'initial output version should be 0' ) ;
462
+
463
+ textModel . applyEdits ( [
464
+ {
465
+ editType : CellEditType . OutputItems ,
466
+ append : true ,
467
+ outputId : 'append1' ,
468
+ items : [ {
469
+ mime : stdOutMime , data : valueBytesFromString ( MOVE_CURSOR_1_LINE_COMMAND + '\nappend 2' )
470
+ } ]
471
+ } ] , true , undefined , ( ) => undefined , undefined , true ) ;
472
+ assert . strictEqual ( output . versionId , 1 , 'version should bump per append' ) ;
473
+
474
+ assert . strictEqual ( output . outputs [ 0 ] . data . toString ( ) , 'append 1\nappend 2' ) ;
475
+ assert . strictEqual ( output . appendedSinceVersion ( 0 , stdOutMime ) , undefined ,
476
+ 'compressing outputs should clear out previous versioned output buffers' ) ;
477
+ }
478
+ ) ;
479
+ } ) ;
480
+
439
481
test ( 'appending multiple different mime streaming outputs' , async function ( ) {
440
482
await withTestNotebook (
441
483
[
0 commit comments