From ea14363a0e291a269abe697eb3f0b7ccd85d89c5 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 20 Oct 2019 20:06:45 -0400 Subject: [PATCH 1/3] #192: handle less-specified initialization --- src/server.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server.ts b/src/server.ts index 2674779e..d52629b6 100755 --- a/src/server.ts +++ b/src/server.ts @@ -347,9 +347,12 @@ connection.onInitialize((params: InitializeParams): InitializeResult => { if (params.rootUri) { workspaceRoot = URI.parse(params.rootUri); } - workspaceFolders = params.workspaceFolders; - hierarchicalDocumentSymbolSupport = !!capabilities.textDocument.documentSymbol.hierarchicalDocumentSymbolSupport; - clientDynamicRegisterSupport = !!(capabilities.textDocument.rangeFormatting && capabilities.textDocument.rangeFormatting.dynamicRegistration); + workspaceFolders = params.workspaceFolders || []; + + const { documentSymbol, rangeFormatting } = capabilities.textDocument || {}; + + hierarchicalDocumentSymbolSupport = !!(documentSymbol && documentSymbol.hierarchicalDocumentSymbolSupport); + clientDynamicRegisterSupport = !!(rangeFormatting && rangeFormatting.dynamicRegistration); return { capabilities: { From e837fe0ba08348de1573ef10e7c62e093d78cc53 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 20 Oct 2019 20:25:55 -0400 Subject: [PATCH 2/3] appease ts3.5 fallback behavior --- src/server.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/server.ts b/src/server.ts index d52629b6..7a526268 100755 --- a/src/server.ts +++ b/src/server.ts @@ -349,10 +349,11 @@ connection.onInitialize((params: InitializeParams): InitializeResult => { } workspaceFolders = params.workspaceFolders || []; - const { documentSymbol, rangeFormatting } = capabilities.textDocument || {}; - - hierarchicalDocumentSymbolSupport = !!(documentSymbol && documentSymbol.hierarchicalDocumentSymbolSupport); - clientDynamicRegisterSupport = !!(rangeFormatting && rangeFormatting.dynamicRegistration); + if (capabilities.textDocument) { + const { documentSymbol, rangeFormatting } = capabilities.textDocument; + hierarchicalDocumentSymbolSupport = !!(documentSymbol && documentSymbol.hierarchicalDocumentSymbolSupport); + clientDynamicRegisterSupport = !!(rangeFormatting && rangeFormatting.dynamicRegistration); + } return { capabilities: { From 8fc85c02c10db86a5e32608e973ec5020783921b Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 20 Oct 2019 20:36:38 -0400 Subject: [PATCH 3/3] back to really long existence checks --- src/server.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/server.ts b/src/server.ts index 7a526268..6aa54e2d 100755 --- a/src/server.ts +++ b/src/server.ts @@ -349,11 +349,16 @@ connection.onInitialize((params: InitializeParams): InitializeResult => { } workspaceFolders = params.workspaceFolders || []; - if (capabilities.textDocument) { - const { documentSymbol, rangeFormatting } = capabilities.textDocument; - hierarchicalDocumentSymbolSupport = !!(documentSymbol && documentSymbol.hierarchicalDocumentSymbolSupport); - clientDynamicRegisterSupport = !!(rangeFormatting && rangeFormatting.dynamicRegistration); - } + hierarchicalDocumentSymbolSupport = !!( + capabilities.textDocument && + capabilities.textDocument.documentSymbol && + capabilities.textDocument.documentSymbol.hierarchicalDocumentSymbolSupport + ); + clientDynamicRegisterSupport = !!( + capabilities.textDocument && + capabilities.textDocument.rangeFormatting && + capabilities.textDocument.rangeFormatting.dynamicRegistration + ); return { capabilities: {