Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/goLanguageServer: replace [] foldingRange response with undefined
In the presence of parse errors, gopls may fail to compute foldingRanges correctly and return only partial results. Partial results can confuse editors and cause to drop still valid, previously known folding ranges information. Currently, LSP does not allow a way for the server to tell clients the server is not ready for answering to the request. VSCode foldingRange API allows registered foldingRange provider to opt out of the folding range computation by providing undefined. https://code.visualstudio.com/api/references/vscode-api#FoldingRangeProvider "Returns a list of folding ranges or null and undefined if the provider does not want to participate or was cancelled." But, LSP currently does not disginguish undefined/null and empty results. Raising an error may be an option, but some LSP clients may not handle errors in user-friendly ways. Thus gopls devs want to avoid raising errors here. With https://go-review.googlesource.com/c/tools/+/291569, gopls will return an empty foldingRange response when encountering parse errors instead of returning incomplete results. This CL adds provideFoldingRanges in the middleware, that converts an empty foldingRange response with 'undefined' if the document is not empty. Manually tested. Testing it in the integration test setup is currently tricky until gopls with the change is released. Updates #1224 Updates golang/go#41281 Change-Id: I32cfb30d7e6a9874b9d1cb6c7e5309f19ee081e5 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/299569 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
- Loading branch information