@@ -849,8 +849,11 @@ func (c *completer) unimportedMembers(ctx context.Context, id *ast.Ident) error
849
849
return nil
850
850
})
851
851
}
852
+ sort .Slice (paths , func (i , j int ) bool {
853
+ return relevances [paths [i ]] > relevances [paths [j ]]
854
+ })
852
855
853
- for path , relevance := range relevances {
856
+ for _ , path := range paths {
854
857
pkg := known [path ]
855
858
if pkg .GetTypes ().Name () != id .Name {
856
859
continue
@@ -862,7 +865,7 @@ func (c *completer) unimportedMembers(ctx context.Context, id *ast.Ident) error
862
865
if imports .ImportPathToAssumedName (path ) != pkg .GetTypes ().Name () {
863
866
imp .name = pkg .GetTypes ().Name ()
864
867
}
865
- c .packageMembers (ctx , pkg .GetTypes (), unimportedScore (relevance ), imp )
868
+ c .packageMembers (ctx , pkg .GetTypes (), unimportedScore (relevances [ path ] ), imp )
866
869
if len (c .items ) >= unimportedMemberTarget {
867
870
return nil
868
871
}
@@ -1134,8 +1137,11 @@ func (c *completer) unimportedPackages(ctx context.Context, seen map[string]stru
1134
1137
return nil
1135
1138
})
1136
1139
}
1140
+ sort .Slice (paths , func (i , j int ) bool {
1141
+ return relevances [paths [i ]] > relevances [paths [j ]]
1142
+ })
1137
1143
1138
- for path , relevance := range relevances {
1144
+ for _ , path := range paths {
1139
1145
pkg := known [path ]
1140
1146
if _ , ok := seen [pkg .GetTypes ().Name ()]; ok {
1141
1147
continue
@@ -1152,7 +1158,7 @@ func (c *completer) unimportedPackages(ctx context.Context, seen map[string]stru
1152
1158
}
1153
1159
c .found (ctx , candidate {
1154
1160
obj : types .NewPkgName (0 , nil , pkg .GetTypes ().Name (), pkg .GetTypes ()),
1155
- score : unimportedScore (relevance ),
1161
+ score : unimportedScore (relevances [ path ] ),
1156
1162
imp : imp ,
1157
1163
})
1158
1164
count ++
0 commit comments