@@ -220,16 +220,26 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
220220 this . id = '$notebookViewModel' + MODEL_ID ;
221221 this . _instanceId = strings . singleLetterHash ( MODEL_ID ) ;
222222
223- // this._register(this._model.onDidChangeCells(e => {
224- // this._onDidChangeViewCells.fire({
225- // synchronous: true,
226- // splices: e.map(splice => {
227- // return [splice[0], splice[1], splice[2].map(cell => {
228- // return createCellViewModel(this.instantiationService, this, cell as NotebookCellTextModel);
229- // })];
230- // })
231- // });
232- // }));
223+ this . _register ( this . _model . onDidChangeCells ( e => {
224+ const diffs = e . map ( splice => {
225+ return [ splice [ 0 ] , splice [ 1 ] , splice [ 2 ] . map ( cell => {
226+ return createCellViewModel ( this . instantiationService , this , cell as NotebookCellTextModel ) ;
227+ } ) ] as [ number , number , CellViewModel [ ] ] ;
228+ } ) ;
229+
230+ diffs . reverse ( ) . forEach ( diff => {
231+ this . _viewCells . splice ( diff [ 0 ] , diff [ 1 ] , ...diff [ 2 ] ) ;
232+ diff [ 2 ] . forEach ( cell => {
233+ this . _handleToViewCellMapping . set ( cell . handle , cell ) ;
234+ this . _localStore . add ( cell ) ;
235+ } ) ;
236+ } ) ;
237+
238+ this . _onDidChangeViewCells . fire ( {
239+ synchronous : true ,
240+ splices : diffs
241+ } ) ;
242+ } ) ) ;
233243
234244 this . _register ( this . _model . notebook . onDidChangeMetadata ( e => {
235245 this . eventDispatcher . emit ( [ new NotebookMetadataChangedEvent ( e ) ] ) ;
0 commit comments