From 22774f7dae43231ae3ff025ca3f8f2c37bdff19b Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Mon, 9 Dec 2019 17:30:27 -0500 Subject: [PATCH] internal/lsp/cache: invalidate metadata even without Create When a new file is opened, the first time we learn about it will be a didOpen event. We need to invalidate the package's metadata in that case too. Fixes golang/go#35638. Change-Id: I36c6171e9c959c48ede9e125679e8dd1be7609f4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/210559 Reviewed-by: Rebecca Stambler --- internal/lsp/cache/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index 275893b6cb..e3242ae54c 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -565,7 +565,7 @@ func (v *view) invalidateContent(ctx context.Context, f source.File, kind source // Make a rough estimate of what metadata to invalidate by finding the package IDs // of all of the files in the same directory as this one. // TODO(rstambler): Speed this up by mapping directories to filenames. - if action == source.Create { + if originalFH == nil { if dirStat, err := os.Stat(dir(f.URI().Filename())); err == nil { for _, uri := range v.snapshot.getFileURIs() { if fdirStat, err := os.Stat(dir(uri.Filename())); err == nil {