fix: guard against optional client capabilities (#602)

for client like lsp-mode for emacs which doesn't have colorProvider,
server is failing to start, and according to the specification, the
capabilities here is all optional, so we should guard the nil situation.
master
A.I 2022-09-12 17:13:02 +08:00 committed by GitHub
parent aeb1595b86
commit d32e11fa60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -1563,10 +1563,10 @@ class DocumentService {
function supportsDynamicRegistration(connection: Connection, params: InitializeParams): boolean {
return (
connection.onInitialized &&
params.capabilities.textDocument.hover.dynamicRegistration &&
params.capabilities.textDocument.colorProvider.dynamicRegistration &&
params.capabilities.textDocument.codeAction.dynamicRegistration &&
params.capabilities.textDocument.completion.dynamicRegistration
params.capabilities.textDocument.hover?.dynamicRegistration &&
params.capabilities.textDocument.colorProvider?.dynamicRegistration &&
params.capabilities.textDocument.codeAction?.dynamicRegistration &&
params.capabilities.textDocument.completion?.dynamicRegistration
)
}