diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs index 1cb4c670..73ceedeb 100644 --- a/harper-ls/src/backend.rs +++ b/harper-ls/src/backend.rs @@ -477,6 +477,22 @@ impl LanguageServer for Backend { async fn did_change_configuration(&self, params: DidChangeConfigurationParams) { self.update_config_from_obj(params.settings).await; + + let urls: Vec = { + let mut doc_lock = self.doc_state.lock().await; + let config_lock = self.config.read().await; + + for doc in doc_lock.values_mut() { + doc.linter = LintGroup::new(config_lock.lint_config, doc.dict.clone()); + } + + doc_lock.keys().cloned().collect() + }; + + for url in urls { + let _ = self.update_document_from_file(&url, None).await; + self.publish_diagnostics(&url).await; + } } async fn code_action(&self, params: CodeActionParams) -> Result> { diff --git a/packages/vscode-plugin/src/extension.ts b/packages/vscode-plugin/src/extension.ts index 7396aacd..3fe4a5a7 100644 --- a/packages/vscode-plugin/src/extension.ts +++ b/packages/vscode-plugin/src/extension.ts @@ -44,8 +44,9 @@ export async function activate(context: ExtensionContext): Promise { context.subscriptions.push( workspace.onDidChangeConfiguration(async (event) => { if (configs.find((c) => event.affectsConfiguration(c))) { - clientOptions.outputChannel?.appendLine('Configuration changed, restarting server'); - await startLanguageServer(); + await client?.sendNotification('workspace/didChangeConfiguration', { + settings: { 'harper-ls': workspace.getConfiguration('harper-ls') } + }); } }) ); diff --git a/packages/vscode-plugin/src/tests/suite/integration.test.ts b/packages/vscode-plugin/src/tests/suite/integration.test.ts index 59475230..98d31b3c 100644 --- a/packages/vscode-plugin/src/tests/suite/integration.test.ts +++ b/packages/vscode-plugin/src/tests/suite/integration.test.ts @@ -47,8 +47,8 @@ describe('Integration >', () => { it('updates diagnostics on configuration change', async () => { const config = workspace.getConfiguration('harper-ls.linters'); await config.update('repeated_words', false, ConfigurationTarget.Workspace); - // Wait for `harper-ls` to restart and send new diagnostics - await sleep(1000); + // Wait for `harper-ls` to update diagnostics + await sleep(250); compareActualVsExpectedDiagnostics( getActualDiagnostics(markdownUri),