From 125cfdbd7b48ecdfa6fbf23afc816d2f10cbf1f0 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Wed, 25 Sep 2019 12:19:15 -0400 Subject: [PATCH] internal/lsp: fix merge conflict and race condition Race condition: I deleted the code that acquired the mutex when checking if a file's imports have changed. Merge conflict: I submitted a change without rebasing and re-running TryBots. Change-Id: Iae351f2fff893cfd94db79d9f79578d9827a8c21 Reviewed-on: https://go-review.googlesource.com/c/tools/+/197297 Run-TryBot: Rebecca Stambler Reviewed-by: Ian Cottrell --- internal/lsp/cache/load.go | 3 +++ internal/lsp/source/completion_literal.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index fad0ec9683..d70e091c85 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -136,6 +136,9 @@ func (v *view) checkMetadata(ctx context.Context, f *goFile, fh source.FileHandl // determine if they have changed. // It assumes that the caller holds the lock on the f.mu lock. func (v *view) shouldRunGopackages(ctx context.Context, f *goFile, file *ast.File, metadata []*metadata) bool { + f.mu.Lock() + defer f.mu.Unlock() + // Check if the package's name has changed, by checking if this is a filename // we already know about, and if so, check if its package name has changed. for _, m := range metadata { diff --git a/internal/lsp/source/completion_literal.go b/internal/lsp/source/completion_literal.go index 4769b0fe50..c8dbafb1bc 100644 --- a/internal/lsp/source/completion_literal.go +++ b/internal/lsp/source/completion_literal.go @@ -284,7 +284,7 @@ func (c *completer) basicLiteral(T types.Type, typeName string, matchScore float InsertText: nonSnippet, Detail: T.String(), Score: matchScore * literalCandidateScore, - Kind: VariableCompletionItem, + Kind: protocol.VariableCompletion, snippet: snip, }) }