@@ -11,7 +11,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language';
1111import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock' ;
1212import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo' ;
1313import { 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' ;
1515import { setupInstantiationService , TestCell , valueBytesFromString , withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor' ;
1616
1717suite ( 'NotebookTextModel' , ( ) => {
@@ -436,6 +436,48 @@ suite('NotebookTextModel', () => {
436436 ) ;
437437 } ) ;
438438
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+
439481 test ( 'appending multiple different mime streaming outputs' , async function ( ) {
440482 await withTestNotebook (
441483 [
0 commit comments