Skip to content

Handle priority change #1110

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
20 changes: 18 additions & 2 deletions packages/jupyterlab-lsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { ILoggerRegistry } from '@jupyterlab/logconsole';
import {
ILSPDocumentConnectionManager,
DocumentConnectionManager,
ILanguageServerManager
ILanguageServerManager,
TLanguageServerId
} from '@jupyterlab/lsp';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { IStatusBar } from '@jupyterlab/statusbar';
Expand Down Expand Up @@ -175,7 +176,22 @@ export class LSPExtension {

const previousInitialConfig = this._connectionManager.initialConfigurations;
this._connectionManager.initialConfigurations = languageServerSettings;
// TODO: if priorities changed reset connections

const prioritiesChanged = Object.keys(languageServerSettings).some(
(key: TLanguageServerId) => {
const prevConfig = previousInitialConfig?.[key];
const newConfig = languageServerSettings[key];
return prevConfig && newConfig && prevConfig.rank !== newConfig.rank;
}
);

if (prioritiesChanged) {
this.connectionManager.adapters.forEach(adapter => {
if (adapter.virtualDocument) {
adapter['reloadConnection']();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we would want to make it public upstream?

Or we could make a public method which calls the protected one here in:

export class NotebookAdapter extends UpstreamNotebookAdapter {

and in

export class FileEditorAdapter extends UpstreamFileEditorAdapter {

but frankly I think it does not need to be protected.

}
});
}

// update the server-independent part of configuration immediately
this.connectionManager.updateConfiguration(languageServerSettings);
Expand Down
Loading