Skip to content

Commit

Permalink
Handle priority change
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jan 9, 2025
1 parent f5d2b9e commit 71bec8d
Showing 1 changed file with 18 additions and 2 deletions.
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']();
}
});
}

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

0 comments on commit 71bec8d

Please sign in to comment.