@@ -27,7 +27,6 @@ import * as vscode from 'vscode';
2727import { Cache } from './cache' ;
2828import { ResourceMap } from 'vs/base/common/map' ;
2929
30-
3130interface IObservable < T > {
3231 proxy : T ;
3332 onDidChange : Event < void > ;
@@ -86,6 +85,8 @@ export class ExtHostCell extends Disposable implements vscode.NotebookCell {
8685 readonly uri : URI ;
8786 readonly cellKind : CellKind ;
8887
88+ private _document : vscode . TextDocument | undefined ;
89+
8990 constructor (
9091 private _proxy : MainThreadNotebookShape ,
9192 readonly notebook : ExtHostNotebookDocument ,
@@ -112,7 +113,10 @@ export class ExtHostCell extends Disposable implements vscode.NotebookCell {
112113 }
113114
114115 get document ( ) : vscode . TextDocument {
115- return this . _extHostDocument . getDocument ( this . uri ) ! . document ;
116+ if ( ! this . _document ) {
117+ this . _document = this . _extHostDocument . getDocument ( this . uri ) ?. document ;
118+ }
119+ return this . _document ! ;
116120 }
117121
118122 get language ( ) : string {
@@ -365,6 +369,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
365369
366370 const contentChangeEvents : vscode . NotebookCellsChangeData [ ] = [ ] ;
367371 const addedCellDocuments : IExtHostModelAddedData [ ] = [ ] ;
372+ const removedCellDocuments : URI [ ] = [ ] ;
368373
369374 splices . reverse ( ) . forEach ( splice => {
370375 const cellDtos = splice [ 2 ] ;
@@ -402,11 +407,16 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
402407 deletedItems,
403408 items : newCells
404409 } ) ;
410+
411+ for ( let cell of deletedItems ) {
412+ removedCellDocuments . push ( cell . uri ) ;
413+ }
405414 } ) ;
406415
407- if ( addedCellDocuments ) {
408- this . _documentsAndEditors . acceptDocumentsAndEditorsDelta ( { addedDocuments : addedCellDocuments } ) ;
409- }
416+ this . _documentsAndEditors . acceptDocumentsAndEditorsDelta ( {
417+ addedDocuments : addedCellDocuments ,
418+ removedDocuments : removedCellDocuments
419+ } ) ;
410420
411421 if ( ! initialization ) {
412422 this . _emitter . emitModelChange ( {
0 commit comments