From 09ab05b0dbdd5bffc33f3847a5a5d187e39d30b6 Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Thu, 13 May 2021 12:50:46 -0400 Subject: [PATCH] internal/lsp: exit graceful for modfiles in semantic tokens Change-Id: I86e6dbdd6e51af9b947c34fd04489ed34687b3c3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/319849 Trust: Robert Findley Run-TryBot: Robert Findley gopls-CI: kokoro Reviewed-by: Heschi Kreinick TryBot-Result: Go Bot --- internal/lsp/semantic.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/lsp/semantic.go b/internal/lsp/semantic.go index d8feea7b9c7..c6e9190aaa4 100644 --- a/internal/lsp/semantic.go +++ b/internal/lsp/semantic.go @@ -77,6 +77,9 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu } return template.SemanticTokens(ctx, snapshot, fh.URI(), add, data) } + if fh.Kind() != source.Go { + return nil, nil + } pkg, err := snapshot.PackageForFile(ctx, fh.URI(), source.TypecheckFull, source.WidestPackage) if err != nil { return nil, err