Skip to content

Commit 8817f9a

Browse files
committed
oops
1 parent 312f63f commit 8817f9a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/notebooks/controllers/notebookIPyWidgetCoordinator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ class NotebookCommunication implements IWebviewCommunication, IDisposable {
2929
private pendingMessages: any[] = [];
3030
private readonly disposables: IDisposable[] = [];
3131
private controllerMessageHandler?: IDisposable;
32-
private controller!: IVSCodeNotebookController;
32+
private controller?: IVSCodeNotebookController;
3333
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3434
private readonly _onDidReceiveMessage = new EventEmitter<any>();
3535
constructor(public readonly editor: NotebookEditor, controller: IVSCodeNotebookController) {
3636
this.changeController(controller);
3737
}
3838
public changeController(controller: IVSCodeNotebookController) {
39-
if (this.controller.id === controller.id) {
39+
if (this.controller?.id === controller.id) {
4040
return;
4141
}
4242
this.controllerMessageHandler?.dispose();
4343
this.controller = controller;
4444
this.controllerMessageHandler = controller.onDidReceiveMessage(
4545
(e) => {
4646
// 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) {
4848
// If the listeners haven't been hooked up, then dont fire the event (nothing listening).
4949
// Instead buffer the messages and fire the events later.
5050
if (this.eventHandlerListening) {
@@ -70,10 +70,10 @@ class NotebookCommunication implements IWebviewCommunication, IDisposable {
7070
}
7171
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7272
public postMessage(message: any): Thenable<boolean> {
73-
return this.controller.postMessage(message, this.editor);
73+
return this.controller!.postMessage(message, this.editor);
7474
}
7575
public asWebviewUri(localResource: Uri): Uri {
76-
return this.controller.asWebviewUri(localResource);
76+
return this.controller!.asWebviewUri(localResource);
7777
}
7878
private sendPendingMessages() {
7979
if (this.pendingMessages.length) {

0 commit comments

Comments
 (0)