Skip to content

Commit 364bdd0

Browse files
findleyrgopherbot
authored andcommitted
gopls/internal/lsp/cache: fix incorrect check for active package
Fix an embarassing oversight of CL 512636: the check for active packages was failing deterministically. Also update the definition benchmark to instrument CPU profiling. Change-Id: I544da1d9395ed5eadf51338a29787e8404848347 Reviewed-on: https://go-review.googlesource.com/c/tools/+/513096 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Auto-Submit: Robert Findley <[email protected]>
1 parent c6e02e3 commit 364bdd0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

gopls/internal/lsp/cache/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func (b *typeCheckBatch) handleSyntaxPackage(ctx context.Context, i int, id Pack
485485
// changes to an open package many LSP clients send several successive
486486
// requests for package information for the modified package (semantic
487487
// tokens, code lens, inlay hints, etc.)
488-
if pkg := b.activePackageCache.getActivePackage(id); ok {
488+
if pkg := b.activePackageCache.getActivePackage(id); pkg != nil {
489489
b.post(i, pkg)
490490
return nil, nil // skip: not checked in this batch
491491
}

gopls/internal/regtest/bench/definition_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ func BenchmarkDefinition(b *testing.B) {
3434
env.GoToDefinition(loc) // pre-warm the query, and open the target file
3535
b.ResetTimer()
3636

37+
if stopAndRecord := startProfileIfSupported(b, env, qualifiedName(test.repo, "definition")); stopAndRecord != nil {
38+
defer stopAndRecord()
39+
}
40+
3741
for i := 0; i < b.N; i++ {
3842
env.GoToDefinition(loc) // pre-warm the query
3943
}

0 commit comments

Comments
 (0)