Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): lsp causes error when reconnecting kernel #71

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/libro-lsp/src/adapters/notebook-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class NotebookAdapter extends WidgetLSPAdapter<LibroView> {
* @param _session - Session context of changed kernel
* @param change - Changed data
*/
async onKernelChanged(): Promise<void> {
onKernelChanged = async (): Promise<void> => {
try {
// note: we need to wait until ready before updating language info
const oldLanguageInfo = this._languageInfo;
Expand All @@ -212,7 +212,7 @@ export class NotebookAdapter extends WidgetLSPAdapter<LibroView> {
// try to reconnect anyway
this.reloadConnection();
}
}
};

/**
* Dispose the widget.
Expand Down Expand Up @@ -397,9 +397,11 @@ export class NotebookAdapter extends WidgetLSPAdapter<LibroView> {
return;
}

this._activeEditorChanged.fire({
editor: this.getCellEditor(libroModel.active)!,
});
if (libroModel.active) {
this._activeEditorChanged.fire({
editor: this.getCellEditor(libroModel.active)!,
});
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/libro-lsp/src/connection-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
* language.
*/
disconnect(languageId: TLanguageServerId): void {
this.disconnect(languageId);
this.disconnectServer(languageId);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/libro-lsp/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection {
if (this.isDisposed) {
return;
}
Object.values(this.serverRequests).forEach((request) => request.clearHandler());
if (this.serverRequests) {
Object.values(this.serverRequests).forEach((request) => request.clearHandler());
}
this.close();
super.dispose();
}
Expand Down
Loading