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 <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go
index fad0ec9..d70e091 100644
--- a/internal/lsp/cache/load.go
+++ b/internal/lsp/cache/load.go
@@ -136,6 +136,9 @@
// 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 4769b0f..c8dbafb 100644
--- a/internal/lsp/source/completion_literal.go
+++ b/internal/lsp/source/completion_literal.go
@@ -284,7 +284,7 @@
InsertText: nonSnippet,
Detail: T.String(),
Score: matchScore * literalCandidateScore,
- Kind: VariableCompletionItem,
+ Kind: protocol.VariableCompletion,
snippet: snip,
})
}