File tree Expand file tree Collapse file tree
src/vs/workbench/contrib/notebook/browser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1230,6 +1230,9 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
12301230
12311231 dispose ( ) {
12321232 this . _isDisposed = true ;
1233+ // dispose webview first
1234+ this . _webview ?. dispose ( ) ;
1235+
12331236 this . notebookService . removeNotebookEditor ( this ) ;
12341237 const keys = Object . keys ( this . _contributions ) ;
12351238 for ( let i = 0 , len = keys . length ; i < len ; i ++ ) {
@@ -1239,7 +1242,6 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
12391242
12401243 this . _localStore . clear ( ) ;
12411244 this . _list ?. dispose ( ) ;
1242- this . _webview ?. dispose ( ) ;
12431245
12441246 this . _overlayContainer . remove ( ) ;
12451247 this . viewModel ?. dispose ( ) ;
Original file line number Diff line number Diff line change @@ -327,6 +327,10 @@ ${loaderJs}
327327 this . _register ( this . webview ) ;
328328
329329 this . _register ( this . webview . onDidClickLink ( link => {
330+ if ( this . _disposed ) {
331+ return ;
332+ }
333+
330334 if ( ! link ) {
331335 return ;
332336 }
@@ -338,6 +342,10 @@ ${loaderJs}
338342 } ) ) ;
339343
340344 this . _register ( this . webview . onDidReload ( ( ) => {
345+ if ( this . _disposed ) {
346+ return ;
347+ }
348+
341349 this . preloadsCache . clear ( ) ;
342350 for ( const [ output , inset ] of this . insetMapping . entries ( ) ) {
343351 this . updateRendererPreloads ( inset . preloads ) ;
@@ -346,6 +354,10 @@ ${loaderJs}
346354 } ) ) ;
347355
348356 this . _register ( this . webview . onMessage ( ( data : IMessage ) => {
357+ if ( this . _disposed ) {
358+ return ;
359+ }
360+
349361 if ( data . __vscode_notebook_message ) {
350362 if ( data . type === 'dimension' ) {
351363 let height = data . data . height ;
@@ -718,6 +730,10 @@ ${loaderJs}
718730 }
719731
720732 private _sendMessageToWebview ( message : ToWebviewMessage ) {
733+ if ( this . _disposed ) {
734+ return ;
735+ }
736+
721737 this . webview . postMessage ( message ) ;
722738 }
723739
@@ -727,6 +743,7 @@ ${loaderJs}
727743
728744 dispose ( ) {
729745 this . _disposed = true ;
746+ this . webview . dispose ( ) ;
730747 super . dispose ( ) ;
731748 }
732749}
You can’t perform that action at this time.
0 commit comments