Skip to content

x/tools/gopls: regression in semantic tokens (Data field is JSON "null") #67885

Closed
@adonovan

Description

@adonovan

@neild reports that neovim with gopls at master produces an error similar to neovim/neovim#21387. I suspect https://go.dev/cl/577655 introduced a shortcut path with a nil Data slice. This patch appears to be an effective workaround:

diff --git a/gopls/internal/server/semantic.go b/gopls/internal/server/semantic.go
index ca3df78e10..7f7a3474d3 100644
--- a/gopls/internal/server/semantic.go
+++ b/gopls/internal/server/semantic.go
@@ -38,7 +38,7 @@ func (s *server) semanticTokens(ctx context.Context, td protocol.TextDocumentIde
                // Previously, an error was returned here to achieve the same effect, but
                // that had the side effect of very noisy "semantictokens are disabled"
                // logs on every keystroke.
-               return new(protocol.SemanticTokens), nil
+               return &protocol.SemanticTokens{Data: []uint32{}}, nil

Metadata

Metadata

Assignees

Labels

NeedsFixThe path to resolution is known, but the work has not been done.goplsIssues related to the Go language server, gopls.release-blocker

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions