1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:54:44 -07:00

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 <rstambler@golang.org>
This commit is contained in:
Heschi Kreinick 2019-12-09 17:30:27 -05:00
parent 115af5e89b
commit 22774f7dae

View File

@ -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 {