Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: Server sends 'window/showDocument' even when client doesn't support it #68904

Open
puremourning opened this issue Aug 15, 2024 · 2 comments
Assignees
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

Comments

@puremourning
Copy link

gopls version

0.16.1

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ben/Library/Caches/go-build'
GOENV='/Users/ben/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS='-modcacherw'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ben/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ben/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/ben/Development/YouCompleteMe/go-jsonnet/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/g3/2g6b5vgj3pz55jg8__0yr6nh0000gn/T/go-build3645871995=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Using a LSP client which does not announce the ShowDocumentClientCapabilities.support as true, issue a codeAction request for any file.

What did you see happen?

The following CodeActions are offered:

FixIt suggestion(s) available at this location. Which one would you like to apply?
1: Browse free symbols
2: Browse documentation for package jsonnet
3: Browse arm64 assembly for float64Cmp
Type number and <Enter> or click with the mouse (q or empty cancels):

When executing the associated command, the gopls server sends window/showDocument requests to the client.

This is a breach of LSP protocol.

What did you expect to see?

The server should not announce these codeActions if their commands require use of unsupported client features.

Editor and settings

LSP client = ycmd

Logs

2024-08-15 22:09:58,087 - DEBUG - TX: Sending message: b'Content-Length: 263\r\n\r\n{"id":3,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[]},"range":{"end":{"character":0,"line":38},"start":{"character":0,"line":37}},"textDocument":{"uri":"file:///Users/ben/Development/YouCompleteMe/go-jsonnet/util.go"}}}'
2024-08-15 22:09:58,092 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","result":[{"title":"Browse free symbols","kind":"source.freesymbols","command":{"title":"Browse free symbols","command":"gopls.free_symbols","arguments":["1",{"uri":"file:///Users/ben/Development/YouCompleteMe/go-jsonnet/util.go","range":{"start":{"line":37,"character":0},"end":{"line":38,"character":0}}}]}},{"title":"Browse documentation for package jsonnet","kind":"source.doc","command":{"title":"Browse documentation for package jsonnet","command":"gopls.doc","arguments":[{"uri":"file:///Users/ben/Development/YouCompleteMe/go-jsonnet/util.go","range":{"start":{"line":37,"character":0},"end":{"line":38,"character":0}}}]}},{"title":"Browse arm64 assembly for float64Cmp","kind":"source.assembly","command":{"title":"Browse arm64 assembly for float64Cmp","command":"gopls.assembly","arguments":["1","github.com/google/go-jsonnet","github.com/google/go-jsonnet.float64Cmp"]}}],"id":3}'
127.0.0.1 - - [15/Aug/2024 22:09:58] "POST /run_completer_command HTTP/1.1" 200 926
2024-08-15 22:10:00,328 - DEBUG - Refreshing file /Users/ben/Development/YouCompleteMe/go-jsonnet/util.go: State is Open -> Open/action None
2024-08-15 22:10:00,328 - DEBUG - TX: Sending message: b'Content-Length: 269\r\n\r\n{"id":4,"jsonrpc":"2.0","method":"workspace/executeCommand","params":{"arguments":["1",{"range":{"end":{"character":0,"line":38},"start":{"character":0,"line":37}},"uri":"file:///Users/ben/Development/YouCompleteMe/go-jsonnet/util.go"}],"command":"gopls.free_symbols"}}'
2024-08-15 22:10:00,333 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"window/showDocument","params":{"uri":"http://127.0.0.1:58173/gopls/YdEPwAbC8ts/freesymbols?file=file%3A%2F%2F%2FUsers%2Fben%2FDevelopment%2FYouCompleteMe%2Fgo-jsonnet%2Futil.go\\u0026range=37:0:38:0\\u0026view=1","external":true,"takeFocus":true},"id":5}'
2024-08-15 22:10:00,334 - DEBUG - TX: Sending response: b'Content-Length: 77\r\n\r\n{"error":{"code":-32601,"message":"Method not found"},"id":5,"jsonrpc":"2.0"}'
2024-08-15 22:10:00,334 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","result":null,"id":4}'
2024-08-15 22:10:00,334 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"2024/08/15 22:10:00 client.showDocument: %v: Method not found\\n"}}'
2024-08-15 22:10:00,335 - ERROR - Server reported: 2024/08/15 22:10:00 client.showDocument: %v: Method not found
@puremourning puremourning added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Aug 15, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 15, 2024
@findleyr
Copy link
Contributor

Thanks for the report. You're right, this was an oversight. We will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

5 participants