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

Have SemanticTokensFull return nil when no symbols are available for the file #3531

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions private/buf/buflsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ func (s *server) SemanticTokensFull(
progress.Begin(ctx, "Processing Tokens")
defer progress.Done(ctx)

// In the case where there are no symbols for the file, we return nil for SemanticTokensFull.
// This is based on the specification for the method textDocument/semanticTokens/full,
// the expected response is the union type `SemanticTokens | null`.
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens
if len(file.symbols) == 0 {
return nil, nil
}

var (
encoded []uint32
prevLine, prevCol uint32
Expand Down
Loading