x/tools/gopls: make it tolerant against non-file scheme DocumentURIs in requests #67225
Labels
Documentation
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Gopls assumes source files are on disk and supports only 'file' scheme document URIs.
Even though some editors support virtual file systems, it expects clients to understand this requirement and send only 'file' scheme document URIs.
CL 543575 tightened the uri check and started to return errors for non-file scheme document URIs, even during the
initialize
request handling. Note error ininitialize
request handling is fatal. As more extensions and features in VS Code are implemented on virtual workspace folders, more users will observe this issue. Before cl/543575, gopls skipped non-file scheme folder URIs.golang/vscode-go#3368: decompiler extension
golang/vscode-go#3375: gitlens extension
For most of document-oriented LSP requests, the VS Code Go plugin sends requests only for go-related files on disk, using the vscode LSP client's document filter settings. But, for folder URIs (
initialize
,didChangeWorkspaceFolders
, ...), the plugin has to implement extra handling and that is currently lacking.Unfortunately, it is tricky to filter non-file scheme folder URIs in the
initialize
request with the current LSP client. See microsoft/vscode-languageserver-node#1470. We can have temporary workaround using subclassing, but I found writing a meaningful test in vscode client side is complicated.Since this limitation is gopls specific, I think it's better to make gopls tolerate non-file scheme document uris, rather than requiring clients to implement their own workarounds. And, I find this problem is easier to handle from gopls side :-). Writing convincing tests in gopls is much easier thank to the existing integration test framework.
To reproduce the problem ourselves, build and install the sample in-memory filesystem extension and open a workspace like
The text was updated successfully, but these errors were encountered: