@@ -734,23 +734,14 @@ func (s *snapshot) getOrLoadIDsForURI(ctx context.Context, uri span.URI) ([]Pack
734
734
// Start with the set of package associations derived from the last load.
735
735
ids := s .meta .ids [uri ]
736
736
737
- hasValidID := false // whether we have any valid package metadata containing uri
738
737
shouldLoad := false // whether any packages containing uri are marked 'shouldLoad'
739
738
for _ , id := range ids {
740
- // TODO(rfindley): remove the defensiveness here. s.meta.metadata[id] must
741
- // exist.
742
- if _ , ok := s .meta .metadata [id ]; ok {
743
- hasValidID = true
744
- }
745
739
if len (s .shouldLoad [id ]) > 0 {
746
740
shouldLoad = true
747
741
}
748
742
}
749
743
750
744
// Check if uri is known to be unloadable.
751
- //
752
- // TODO(rfindley): shouldn't we also mark uri as unloadable if the load below
753
- // fails? Otherwise we endlessly load files with no packages.
754
745
_ , unloadable := s .unloadableFiles [uri ]
755
746
756
747
s .mu .Unlock ()
@@ -759,7 +750,7 @@ func (s *snapshot) getOrLoadIDsForURI(ctx context.Context, uri span.URI) ([]Pack
759
750
// - uri is not contained in any valid packages
760
751
// - ...or one of the packages containing uri is marked 'shouldLoad'
761
752
// - ...but uri is not unloadable
762
- if (shouldLoad || ! hasValidID ) && ! unloadable {
753
+ if (shouldLoad || len ( ids ) == 0 ) && ! unloadable {
763
754
scope := fileLoadScope (uri )
764
755
err := s .load (ctx , false , scope )
765
756
@@ -788,14 +779,11 @@ func (s *snapshot) getOrLoadIDsForURI(ctx context.Context, uri span.URI) ([]Pack
788
779
789
780
s .mu .Lock ()
790
781
ids = s .meta .ids [uri ]
791
- var validIDs []PackageID
792
- for _ , id := range ids {
793
- // TODO(rfindley): remove the defensiveness here as well.
794
- if _ , ok := s .meta .metadata [id ]; ok {
795
- validIDs = append (validIDs , id )
796
- }
782
+ // metadata is only ever added by loading, so if we get here and still have
783
+ // no ids, uri is unloadable.
784
+ if ! unloadable && len (ids ) == 0 {
785
+ s .unloadableFiles [uri ] = struct {}{}
797
786
}
798
- ids = validIDs
799
787
s .mu .Unlock ()
800
788
801
789
return ids , nil
@@ -1745,6 +1733,8 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
1745
1733
// TODO(rfindley): this looks wrong. Shouldn't we clear unloadableFiles on
1746
1734
// changes to environment or workspace layout, or more generally on any
1747
1735
// metadata change?
1736
+ //
1737
+ // Maybe not, as major configuration changes cause a new view.
1748
1738
for k , v := range s .unloadableFiles {
1749
1739
result .unloadableFiles [k ] = v
1750
1740
}
0 commit comments