@@ -8,7 +8,7 @@ import { Emitter, Event } from 'vs/base/common/event';
88import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
99import { URI } from 'vs/base/common/uri' ;
1010import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel' ;
11- import { INotebookTextModel , NotebookCellOutputsSplice , NotebookCellTextModelSplice , NotebookDocumentMetadata , NotebookCellMetadata , ICellEditOperation , CellEditType , CellUri , NotebookCellsChangedEvent , CellKind , IProcessedOutput , notebookDocumentMetadataDefaults , diff , NotebookCellsChangeType , ICellDto2 , IMainCellDto , TransientMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
11+ import { INotebookTextModel , NotebookCellOutputsSplice , NotebookCellTextModelSplice , NotebookDocumentMetadata , NotebookCellMetadata , ICellEditOperation , CellEditType , CellUri , NotebookCellsChangedEvent , CellKind , IProcessedOutput , notebookDocumentMetadataDefaults , diff , NotebookCellsChangeType , ICellDto2 , IMainCellDto , TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
1212import { ITextSnapshot } from 'vs/editor/common/model' ;
1313import { IUndoRedoService , UndoRedoElementType , IUndoRedoElement , IResourceUndoRedoElement } from 'vs/platform/undoRedo/common/undoRedo' ;
1414import { InsertCellEdit , DeleteCellEdit , MoveCellEdit , SpliceCellsEdit , CellMetadataEdit } from 'vs/workbench/contrib/notebook/common/model/cellEdit' ;
@@ -128,7 +128,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
128128 cells : NotebookCellTextModel [ ] ;
129129 languages : string [ ] = [ ] ;
130130 metadata : NotebookDocumentMetadata = notebookDocumentMetadataDefaults ;
131- transientMetadata : TransientMetadata = { } ;
131+ transientOptions : TransientOptions = { transientMetadata : { } , transientOutputs : false } ;
132132 private _isUntitled : boolean | undefined = undefined ;
133133 private _versionId = 0 ;
134134
@@ -187,7 +187,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
187187 ) {
188188 const cellHandle = this . _cellhandlePool ++ ;
189189 const cellUri = CellUri . generate ( this . uri , cellHandle ) ;
190- return new NotebookCellTextModel ( cellUri , cellHandle , source , language , cellKind , outputs || [ ] , metadata || { } , this . _modelService ) ;
190+ return new NotebookCellTextModel ( cellUri , cellHandle , source , language , cellKind , outputs || [ ] , metadata || { } , this . transientOptions , this . _modelService ) ;
191191 }
192192
193193 initialize ( cells : ICellDto2 [ ] ) {
@@ -197,7 +197,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
197197 const mainCells = cells . map ( cell => {
198198 const cellHandle = this . _cellhandlePool ++ ;
199199 const cellUri = CellUri . generate ( this . uri , cellHandle ) ;
200- return new NotebookCellTextModel ( cellUri , cellHandle , cell . source , cell . language , cell . cellKind , cell . outputs || [ ] , cell . metadata , this . _modelService ) ;
200+ return new NotebookCellTextModel ( cellUri , cellHandle , cell . source , cell . language , cell . cellKind , cell . outputs || [ ] , cell . metadata , this . transientOptions , this . _modelService ) ;
201201 } ) ;
202202
203203 this . _isUntitled = false ;
@@ -245,7 +245,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
245245 const mainCells = edit . cells . map ( cell => {
246246 const cellHandle = this . _cellhandlePool ++ ;
247247 const cellUri = CellUri . generate ( this . uri , cellHandle ) ;
248- return new NotebookCellTextModel ( cellUri , cellHandle , cell . source , cell . language , cell . cellKind , cell . outputs || [ ] , cell . metadata , this . _modelService ) ;
248+ return new NotebookCellTextModel ( cellUri , cellHandle , cell . source , cell . language , cell . cellKind , cell . outputs || [ ] , cell . metadata , this . transientOptions , this . _modelService ) ;
249249 } ) ;
250250 this . insertNewCell ( edit . index , mainCells , false ) ;
251251 break ;
@@ -473,6 +473,12 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
473473 spliceNotebookCellOutputs ( cellHandle : number , splices : NotebookCellOutputsSplice [ ] ) : void {
474474 const cell = this . _mapping . get ( cellHandle ) ;
475475 cell ?. spliceNotebookCellOutputs ( splices ) ;
476+
477+ if ( ! this . transientOptions . transientOutputs ) {
478+ this . _increaseVersionId ( ) ;
479+ this . setDirty ( true ) ;
480+ this . _onDidChangeContent . fire ( ) ;
481+ }
476482 }
477483
478484 clearCellOutput ( handle : number ) {
@@ -497,13 +503,13 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
497503 }
498504 }
499505
500- private _compareCellMetadata ( a : NotebookCellMetadata , b : NotebookCellMetadata ) {
506+ private _isCellMetadataChanged ( a : NotebookCellMetadata , b : NotebookCellMetadata ) {
501507 const keys = new Set ( [ ...Object . keys ( a || { } ) , ...Object . keys ( b || { } ) ] ) ;
502508 for ( let key of keys ) {
503509 if (
504510 ( a [ key as keyof NotebookCellMetadata ] !== b [ key as keyof NotebookCellMetadata ] )
505511 &&
506- ! ( this . transientMetadata [ key as keyof NotebookCellMetadata ] )
512+ ! ( this . transientOptions . transientMetadata [ key as keyof NotebookCellMetadata ] )
507513 ) {
508514 return true ;
509515 }
@@ -519,7 +525,11 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
519525 return ;
520526 }
521527
522- const triggerDirtyChange = this . _compareCellMetadata ( cell . metadata , metadata ) ;
528+ if ( ! this . _isCellMetadataChanged ( cell . metadata , metadata ) ) {
529+ return ;
530+ }
531+
532+ const triggerDirtyChange = this . _isCellMetadataChanged ( cell . metadata , metadata ) ;
523533
524534 if ( triggerDirtyChange ) {
525535 if ( pushUndoStop ) {
0 commit comments