Skip to content

Commit 77e1ed1

Browse files
committed
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.
1 parent eed44dd commit 77e1ed1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/server.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export default class BashServer {
138138
*/
139139
public register(connection: LSP.Connection): void {
140140
const hasConfigurationCapability = !!this.clientCapabilities?.workspace?.configuration
141+
const canDynamicallyRegisterConfigurationChangeNotification =
142+
!!this.clientCapabilities?.workspace?.didChangeConfiguration?.dynamicRegistration
141143

142144
let currentDocument: TextDocument | null = null
143145
let initialized = false // Whether the client finished initializing
@@ -190,9 +192,11 @@ export default class BashServer {
190192

191193
if (hasConfigurationCapability) {
192194
// Register event for all configuration changes.
193-
connection.client.register(LSP.DidChangeConfigurationNotification.type, {
194-
section: CONFIGURATION_SECTION,
195-
})
195+
if (canDynamicallyRegisterConfigurationChangeNotification) {
196+
connection.client.register(LSP.DidChangeConfigurationNotification.type, {
197+
section: CONFIGURATION_SECTION,
198+
})
199+
}
196200

197201
// get current configuration from client
198202
const configObject = await connection.workspace.getConfiguration(

0 commit comments

Comments
 (0)