Skip to content

Commit d163a21

Browse files
committed
Handle priority change
1 parent ec483e9 commit d163a21

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/jupyterlab-lsp/src/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { ILoggerRegistry } from '@jupyterlab/logconsole';
2020
import {
2121
ILSPDocumentConnectionManager,
2222
DocumentConnectionManager,
23-
ILanguageServerManager
23+
ILanguageServerManager,
24+
TLanguageServerId
2425
} from '@jupyterlab/lsp';
2526
import { ISettingRegistry } from '@jupyterlab/settingregistry';
2627
import { IStatusBar } from '@jupyterlab/statusbar';
@@ -175,7 +176,22 @@ export class LSPExtension {
175176

176177
const previousInitialConfig = this._connectionManager.initialConfigurations;
177178
this._connectionManager.initialConfigurations = languageServerSettings;
178-
// TODO: if priorities changed reset connections
179+
180+
const prioritiesChanged = Object.keys(languageServerSettings).some(
181+
(key: TLanguageServerId) => {
182+
const prevConfig = previousInitialConfig?.[key];
183+
const newConfig = languageServerSettings[key];
184+
return prevConfig && newConfig && prevConfig.rank !== newConfig.rank;
185+
}
186+
);
187+
188+
if (prioritiesChanged) {
189+
this.connectionManager.adapters.forEach(adapter => {
190+
if (adapter.virtualDocument) {
191+
adapter['reloadConnection']();
192+
}
193+
});
194+
}
179195

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

0 commit comments

Comments
 (0)