@@ -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 . _modelService ) ;
191191 }
192192
193193 initialize ( cells : ICellDto2 [ ] ) {
@@ -497,59 +497,22 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
497497 }
498498 }
499499
500- private _compareCellMetadata ( a : NotebookCellMetadata | undefined , b : NotebookCellMetadata | undefined ) {
501- if ( a ?. editable !== b ?. editable && ! this . transientMetadata . editable ) {
502- return true ;
503- }
504-
505- if ( a ?. runnable !== b ?. runnable && ! this . transientMetadata . runnable ) {
506- return true ;
507- }
508-
509- if ( a ?. breakpointMargin !== b ?. breakpointMargin && ! this . transientMetadata . breakpointMargin ) {
510- return true ;
511- }
512-
513- if ( a ?. hasExecutionOrder !== b ?. hasExecutionOrder && ! this . transientMetadata . hasExecutionOrder ) {
514- return true ;
515- }
516-
517- if ( a ?. executionOrder !== b ?. executionOrder && ! this . transientMetadata . executionOrder ) {
518- return true ;
519- }
520-
521- if ( a ?. statusMessage !== b ?. statusMessage && ! this . transientMetadata . statusMessage ) {
522- return true ;
523- }
524-
525- if ( a ?. runState !== b ?. runState && ! this . transientMetadata . runState ) {
526- return true ;
527- }
528-
529- if ( a ?. runStartTime !== b ?. runStartTime && ! this . transientMetadata . runStartTime ) {
530- return true ;
531- }
532-
533- if ( a ?. lastRunDuration !== b ?. lastRunDuration && ! this . transientMetadata . lastRunDuration ) {
534- return true ;
535- }
536-
537- if ( a ?. inputCollapsed !== b ?. inputCollapsed && ! this . transientMetadata . inputCollapsed ) {
538- return true ;
539- }
540-
541- if ( a ?. outputCollapsed !== b ?. outputCollapsed && ! this . transientMetadata . outputCollapsed ) {
542- return true ;
543- }
544-
545- if ( a ?. custom !== b ?. custom && ! this . transientMetadata . custom ) {
546- return true ;
500+ private _compareCellMetadata ( a : NotebookCellMetadata , b : NotebookCellMetadata ) {
501+ const keys = new Set ( [ ...Object . keys ( a || { } ) , ...Object . keys ( b || { } ) ] ) ;
502+ for ( let key of keys ) {
503+ if (
504+ ( a [ key as keyof NotebookCellMetadata ] !== b [ key as keyof NotebookCellMetadata ] )
505+ &&
506+ ! ( this . transientMetadata [ key as keyof NotebookCellMetadata ] )
507+ ) {
508+ return true ;
509+ }
547510 }
548511
549512 return false ;
550513 }
551514
552- changeCellMetadata ( handle : number , metadata : NotebookCellMetadata | undefined , pushUndoStop : boolean ) {
515+ changeCellMetadata ( handle : number , metadata : NotebookCellMetadata , pushUndoStop : boolean ) {
553516 const cell = this . cells . find ( cell => cell . handle === handle ) ;
554517
555518 if ( ! cell ) {
0 commit comments