@@ -1775,16 +1775,18 @@ func (s *Snapshot) clone(ctx, bgCtx context.Context, changed StateChange, done f
1775
1775
// Compute invalidations based on file changes.
1776
1776
anyImportDeleted := false // import deletions can resolve cycles
1777
1777
anyFileOpenedOrClosed := false // opened files affect workspace packages
1778
- anyFileAdded := false // adding a file can resolve missing dependencies
1778
+ anyPkgFileChanged := false // adding a file to a package can resolve missing dependencies
1779
1779
1780
1780
for uri , newFH := range changedFiles {
1781
1781
// The original FileHandle for this URI is cached on the snapshot.
1782
1782
oldFH := oldFiles [uri ] // may be nil
1783
1783
_ , oldOpen := oldFH .(* overlay )
1784
1784
_ , newOpen := newFH .(* overlay )
1785
1785
1786
+ // TODO(rfindley): consolidate with 'metadataChanges' logic below, which
1787
+ // also considers existential changes.
1786
1788
anyFileOpenedOrClosed = anyFileOpenedOrClosed || (oldOpen != newOpen )
1787
- anyFileAdded = anyFileAdded || (oldFH == nil || ! fileExists (oldFH )) && fileExists (newFH )
1789
+ anyPkgFileChanged = anyPkgFileChanged || (oldFH == nil || ! fileExists (oldFH )) && fileExists (newFH )
1788
1790
1789
1791
// If uri is a Go file, check if it has changed in a way that would
1790
1792
// invalidate metadata. Note that we can't use s.view.FileKind here,
@@ -1802,6 +1804,7 @@ func (s *Snapshot) clone(ctx, bgCtx context.Context, changed StateChange, done f
1802
1804
1803
1805
invalidateMetadata = invalidateMetadata || reinit
1804
1806
anyImportDeleted = anyImportDeleted || importDeleted
1807
+ anyPkgFileChanged = anyPkgFileChanged || pkgFileChanged
1805
1808
1806
1809
// Mark all of the package IDs containing the given file.
1807
1810
filePackageIDs := invalidatedPackageIDs (uri , s .meta .IDs , pkgFileChanged )
@@ -1878,7 +1881,7 @@ func (s *Snapshot) clone(ctx, bgCtx context.Context, changed StateChange, done f
1878
1881
// We could be smart here and try to guess which packages may have been
1879
1882
// fixed, but until that proves necessary, just invalidate metadata for any
1880
1883
// package with missing dependencies.
1881
- if anyFileAdded {
1884
+ if anyPkgFileChanged {
1882
1885
for id , mp := range s .meta .Packages {
1883
1886
for _ , impID := range mp .DepsByImpPath {
1884
1887
if impID == "" { // missing import
0 commit comments