@@ -44,7 +44,6 @@ function getObservable<T extends Object>(obj: T): IObservable<T> {
4444
4545interface INotebookEventEmitter {
4646 emitModelChange ( events : vscode . NotebookCellsChangeEvent ) : void ;
47- emitMoveChange ( event : vscode . NotebookCellMoveEvent ) : void ;
4847 emitCellOutputsChange ( event : vscode . NotebookCellOutputsChangeEvent ) : void ;
4948 emitCellLanguageChange ( event : vscode . NotebookCellLanguageChangeEvent ) : void ;
5049}
@@ -262,7 +261,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
262261 accpetModelChanged ( event : NotebookCellsChangedEvent ) : void {
263262 this . _versionId = event . versionId ;
264263 if ( event . kind === NotebookCellsChangeType . ModelChange ) {
265- this . $spliceNotebookCells ( event . changes ) ;
264+ this . $spliceNotebookCells ( event . change ) ;
266265 } else if ( event . kind === NotebookCellsChangeType . Move ) {
267266 this . $moveCell ( event . index , event . newIdx ) ;
268267 } else if ( event . kind === NotebookCellsChangeType . CellClearOutput ) {
@@ -274,56 +273,50 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
274273 }
275274 }
276275
277- private $spliceNotebookCells ( splices : NotebookCellsSplice2 [ ] ) : void {
276+ private $spliceNotebookCells ( splice : NotebookCellsSplice2 ) : void {
278277 if ( this . _disposed ) {
279278 return ;
280279 }
281280
282- if ( ! splices . length ) {
283- return ;
284- }
285-
286281 let contentChangeEvents : vscode . NotebookCellsChangeData [ ] = [ ] ;
287282
288- splices . reverse ( ) . forEach ( splice => {
289- let cellDtos = splice [ 2 ] ;
290- let newCells = cellDtos . map ( cell => {
291- const extCell = new ExtHostCell ( this . viewType , this . uri , cell . handle , URI . revive ( cell . uri ) , cell . source . join ( '\n' ) , cell . cellKind , cell . language , cell . outputs , cell . metadata , this . _proxy ) ;
292- const documentData = this . _documentsAndEditors . getDocument ( URI . revive ( cell . uri ) ) ;
283+ let cellDtos = splice [ 2 ] ;
284+ let newCells = cellDtos . map ( cell => {
285+ const extCell = new ExtHostCell ( this . viewType , this . uri , cell . handle , URI . revive ( cell . uri ) , cell . source . join ( '\n' ) , cell . cellKind , cell . language , cell . outputs , cell . metadata , this . _proxy ) ;
286+ const documentData = this . _documentsAndEditors . getDocument ( URI . revive ( cell . uri ) ) ;
293287
294- if ( documentData ) {
295- extCell . attachTextDocument ( documentData ) ;
296- }
288+ if ( documentData ) {
289+ extCell . attachTextDocument ( documentData ) ;
290+ }
297291
298- if ( ! this . _cellDisposableMapping . has ( extCell . handle ) ) {
299- this . _cellDisposableMapping . set ( extCell . handle , new DisposableStore ( ) ) ;
300- }
292+ if ( ! this . _cellDisposableMapping . has ( extCell . handle ) ) {
293+ this . _cellDisposableMapping . set ( extCell . handle , new DisposableStore ( ) ) ;
294+ }
301295
302- let store = this . _cellDisposableMapping . get ( extCell . handle ) ! ;
296+ let store = this . _cellDisposableMapping . get ( extCell . handle ) ! ;
303297
304- store . add ( extCell . onDidChangeOutputs ( ( diffs ) => {
305- this . eventuallyUpdateCellOutputs ( extCell , diffs ) ;
306- } ) ) ;
298+ store . add ( extCell . onDidChangeOutputs ( ( diffs ) => {
299+ this . eventuallyUpdateCellOutputs ( extCell , diffs ) ;
300+ } ) ) ;
307301
308- return extCell ;
309- } ) ;
302+ return extCell ;
303+ } ) ;
310304
311- for ( let j = splice [ 0 ] ; j < splice [ 0 ] + splice [ 1 ] ; j ++ ) {
312- this . _cellDisposableMapping . get ( this . cells [ j ] . handle ) ?. dispose ( ) ;
313- this . _cellDisposableMapping . delete ( this . cells [ j ] . handle ) ;
305+ for ( let j = splice [ 0 ] ; j < splice [ 0 ] + splice [ 1 ] ; j ++ ) {
306+ this . _cellDisposableMapping . get ( this . cells [ j ] . handle ) ?. dispose ( ) ;
307+ this . _cellDisposableMapping . delete ( this . cells [ j ] . handle ) ;
314308
315- }
309+ }
316310
317- this . cells . splice ( splice [ 0 ] , splice [ 1 ] , ...newCells ) ;
311+ this . cells . splice ( splice [ 0 ] , splice [ 1 ] , ...newCells ) ;
318312
319- const event : vscode . NotebookCellsChangeData = {
320- start : splice [ 0 ] ,
321- deletedCount : splice [ 1 ] ,
322- items : newCells
323- } ;
313+ const event : vscode . NotebookCellsChangeData = {
314+ start : splice [ 0 ] ,
315+ deletedCount : splice [ 1 ] ,
316+ items : newCells
317+ } ;
324318
325- contentChangeEvents . push ( event ) ;
326- } ) ;
319+ contentChangeEvents . push ( event ) ;
327320
328321 this . _emitter . emitModelChange ( {
329322 document : this ,
@@ -334,8 +327,19 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
334327 private $moveCell ( index : number , newIdx : number ) : void {
335328 const cells = this . cells . splice ( index , 1 ) ;
336329 this . cells . splice ( newIdx , 0 , ...cells ) ;
337- const event : vscode . NotebookCellMoveEvent = { document : this , index, newIndex : newIdx } ;
338- this . _emitter . emitMoveChange ( event ) ;
330+ const changes : vscode . NotebookCellsChangeData [ ] = [ {
331+ start : index ,
332+ deletedCount : 1 ,
333+ items : [ ]
334+ } , {
335+ start : newIdx ,
336+ deletedCount : 0 ,
337+ items : cells
338+ } ] ;
339+ this . _emitter . emitModelChange ( {
340+ document : this ,
341+ changes
342+ } ) ;
339343 }
340344
341345 private $clearCellOutputs ( index : number ) : void {
@@ -715,8 +719,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
715719 private readonly _notebookOutputRenderers = new Map < number , ExtHostNotebookOutputRenderer > ( ) ;
716720 private readonly _onDidChangeNotebookCells = new Emitter < vscode . NotebookCellsChangeEvent > ( ) ;
717721 readonly onDidChangeNotebookCells = this . _onDidChangeNotebookCells . event ;
718- private readonly _onDidMoveNotebookCell = new Emitter < vscode . NotebookCellMoveEvent > ( ) ;
719- readonly onDidMoveNotebookCell = this . _onDidMoveNotebookCell . event ;
720722 private readonly _onDidChangeCellOutputs = new Emitter < vscode . NotebookCellOutputsChangeEvent > ( ) ;
721723 readonly onDidChangeCellOutputs = this . _onDidChangeCellOutputs . event ;
722724 private readonly _onDidChangeCellLanguage = new Emitter < vscode . NotebookCellLanguageChangeEvent > ( ) ;
@@ -849,9 +851,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
849851 emitModelChange ( event : vscode . NotebookCellsChangeEvent ) : void {
850852 that . _onDidChangeNotebookCells . fire ( event ) ;
851853 } ,
852- emitMoveChange ( event : vscode . NotebookCellMoveEvent ) : void {
853- that . _onDidMoveNotebookCell . fire ( event ) ;
854- } ,
855854 emitCellOutputsChange ( event : vscode . NotebookCellOutputsChangeEvent ) : void {
856855 that . _onDidChangeCellOutputs . fire ( event ) ;
857856 } ,
@@ -1158,9 +1157,6 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
11581157 emitModelChange ( event : vscode . NotebookCellsChangeEvent ) : void {
11591158 that . _onDidChangeNotebookCells . fire ( event ) ;
11601159 } ,
1161- emitMoveChange ( event : vscode . NotebookCellMoveEvent ) : void {
1162- that . _onDidMoveNotebookCell . fire ( event ) ;
1163- } ,
11641160 emitCellOutputsChange ( event : vscode . NotebookCellOutputsChangeEvent ) : void {
11651161 that . _onDidChangeCellOutputs . fire ( event ) ;
11661162 } ,
@@ -1180,12 +1176,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
11801176 document . accpetModelChanged ( {
11811177 kind : NotebookCellsChangeType . ModelChange ,
11821178 versionId : modelData . versionId ,
1183- changes : [
1184- [
1185- 0 ,
1186- 0 ,
1187- modelData . cells
1188- ]
1179+ change : [
1180+ 0 ,
1181+ 0 ,
1182+ modelData . cells
11891183 ]
11901184 } ) ;
11911185
0 commit comments