From d1d6cdd8a67e21a0b648ba78eaa5730d0d447ca7 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Fri, 14 Jun 2019 14:10:39 -0400 Subject: [PATCH] internal/lsp: clear out missing imports set when we re-load package This change ensures that we always populate a new set of missing imports when we re-load a package. Otherwise, we might keep stale missing imports around. Change-Id: Id9b6b8201e3ed093a7b9ece97a81e298de612a5e Reviewed-on: https://go-review.googlesource.com/c/tools/+/182459 Run-TryBot: Rebecca Stambler Reviewed-by: Ian Cottrell --- internal/lsp/cache/load.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index c8963fd8..335ad065 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -145,12 +145,11 @@ func (v *view) link(ctx context.Context, pkgPath packagePath, pkg *packages.Pack // If we haven't seen this package before. if !ok { m = &metadata{ - pkgPath: pkgPath, - id: id, - typesSizes: pkg.TypesSizes, - parents: make(map[packageID]bool), - children: make(map[packageID]bool), - missingImports: make(map[packagePath]struct{}), + pkgPath: pkgPath, + id: id, + typesSizes: pkg.TypesSizes, + parents: make(map[packageID]bool), + children: make(map[packageID]bool), } v.mcache.packages[id] = m v.mcache.ids[pkgPath] = id @@ -172,6 +171,7 @@ func (v *view) link(ctx context.Context, pkgPath packagePath, pkg *packages.Pack m.parents[parent.id] = true parent.children[id] = true } + m.missingImports = make(map[packagePath]struct{}) for importPath, importPkg := range pkg.Imports { if len(importPkg.Errors) > 0 { m.missingImports[pkgPath] = struct{}{}