Skip to content

Commit 6073dd1

Browse files
author
jiacai2050
committed
internal/lsp: return when whyList less than require.
Fixes #37977
1 parent 0d839f3 commit 6073dd1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/lsp/cache/mod.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ func goModWhy(ctx context.Context, cfg *packages.Config, folder string, data *mo
225225
return err
226226
}
227227
whyList := strings.Split(stdout.String(), "\n\n")
228-
if len(whyList) <= 1 || len(whyList) > len(data.origParsedFile.Require) {
228+
if len(whyList) <= 1 || len(whyList) < len(data.origParsedFile.Require) {
229229
return nil
230230
}
231-
data.why = make(map[string]string)
231+
data.why = make(map[string]string, len(data.origParsedFile.Require))
232232
for i, req := range data.origParsedFile.Require {
233233
data.why[req.Mod.Path] = whyList[i]
234234
}

0 commit comments

Comments
 (0)