@@ -29,22 +29,22 @@ class NotebookCommunication implements IWebviewCommunication, IDisposable {
29
29
private pendingMessages : any [ ] = [ ] ;
30
30
private readonly disposables : IDisposable [ ] = [ ] ;
31
31
private controllerMessageHandler ?: IDisposable ;
32
- private controller ! : IVSCodeNotebookController ;
32
+ private controller ? : IVSCodeNotebookController ;
33
33
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
34
private readonly _onDidReceiveMessage = new EventEmitter < any > ( ) ;
35
35
constructor ( public readonly editor : NotebookEditor , controller : IVSCodeNotebookController ) {
36
36
this . changeController ( controller ) ;
37
37
}
38
38
public changeController ( controller : IVSCodeNotebookController ) {
39
- if ( this . controller . id === controller . id ) {
39
+ if ( this . controller ? .id === controller . id ) {
40
40
return ;
41
41
}
42
42
this . controllerMessageHandler ?. dispose ( ) ;
43
43
this . controller = controller ;
44
44
this . controllerMessageHandler = controller . onDidReceiveMessage (
45
45
( e ) => {
46
46
// Handle messages from this only if its still the active controller.
47
- if ( e . editor === this . editor && this . controller . id === controller . id ) {
47
+ if ( e . editor === this . editor && this . controller ? .id === controller . id ) {
48
48
// If the listeners haven't been hooked up, then dont fire the event (nothing listening).
49
49
// Instead buffer the messages and fire the events later.
50
50
if ( this . eventHandlerListening ) {
@@ -70,10 +70,10 @@ class NotebookCommunication implements IWebviewCommunication, IDisposable {
70
70
}
71
71
// eslint-disable-next-line @typescript-eslint/no-explicit-any
72
72
public postMessage ( message : any ) : Thenable < boolean > {
73
- return this . controller . postMessage ( message , this . editor ) ;
73
+ return this . controller ! . postMessage ( message , this . editor ) ;
74
74
}
75
75
public asWebviewUri ( localResource : Uri ) : Uri {
76
- return this . controller . asWebviewUri ( localResource ) ;
76
+ return this . controller ! . asWebviewUri ( localResource ) ;
77
77
}
78
78
private sendPendingMessages ( ) {
79
79
if ( this . pendingMessages . length ) {
0 commit comments