Skip to content

Commit

Permalink
Have SemanticTokensFull return nil on no symbols instead
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Dec 12, 2024
1 parent 89ed18e commit 4c95baf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion private/buf/buflsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,18 @@ 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
)
encoded := []uint32{}
for i, symbol := range file.symbols {
progress.Report(ctx, fmt.Sprintf("%d/%d", i+1, len(file.symbols)), float64(i)/float64(len(file.symbols)))

Expand Down

0 comments on commit 4c95baf

Please sign in to comment.