From 77e1ed16fbb1d5819558217c50f463b756fe2d6e Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 9 Mar 2023 11:55:23 -0600 Subject: [PATCH 1/2] server: Only perform dynamic registration if client supports it The server shouldn't send a `client/registerCapability` unless the client signals support with the dynamicRegistration client capability set to true for didChangeConfiguration. This change checks that field before attempting to register for config change notifications. --- server/src/server.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index d2794d320..1547d6707 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -138,6 +138,8 @@ export default class BashServer { */ public register(connection: LSP.Connection): void { const hasConfigurationCapability = !!this.clientCapabilities?.workspace?.configuration + const canDynamicallyRegisterConfigurationChangeNotification = + !!this.clientCapabilities?.workspace?.didChangeConfiguration?.dynamicRegistration let currentDocument: TextDocument | null = null let initialized = false // Whether the client finished initializing @@ -190,9 +192,11 @@ export default class BashServer { if (hasConfigurationCapability) { // Register event for all configuration changes. - connection.client.register(LSP.DidChangeConfigurationNotification.type, { - section: CONFIGURATION_SECTION, - }) + if (canDynamicallyRegisterConfigurationChangeNotification) { + connection.client.register(LSP.DidChangeConfigurationNotification.type, { + section: CONFIGURATION_SECTION, + }) + } // get current configuration from client const configObject = await connection.workspace.getConfiguration( From 8d7258eb7fd2a7194cd96b07524025fb6dc92e05 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 9 Mar 2023 12:52:50 -0600 Subject: [PATCH 2/2] Bump server version to 4.8.3 --- server/CHANGELOG.md | 4 ++++ server/package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/CHANGELOG.md b/server/CHANGELOG.md index 51c490c18..a2e72fff2 100644 --- a/server/CHANGELOG.md +++ b/server/CHANGELOG.md @@ -1,5 +1,9 @@ # Bash Language Server +## 4.8.3 + +- Skip sending a `client/registerCapability` request when dynamic capability registration is not supported by the client https://github.com/bash-lsp/bash-language-server/pull/763 + ## 4.8.2 - ShellCheck: avoid using the diagnostic tag "deprecated" that allow clients to render diagnostics with a strike through https://github.com/bash-lsp/bash-language-server/pull/753 diff --git a/server/package.json b/server/package.json index ed79840fc..a31414e62 100644 --- a/server/package.json +++ b/server/package.json @@ -3,7 +3,7 @@ "description": "A language server for Bash", "author": "Mads Hartmann", "license": "MIT", - "version": "4.8.2", + "version": "4.8.3", "main": "./out/server.js", "typings": "./out/server.d.ts", "bin": {