Skip to content

Commit

Permalink
Have SemanticTokensFull return nil when no symbols are available …
Browse files Browse the repository at this point in the history
…for the file (#3531)
  • Loading branch information
doriable authored Dec 12, 2024
1 parent 4f48042 commit 1539cac
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit 1539cac

Please sign in to comment.