mirror of https://github.com/golang/go.git
internal/lsp: fix mod file codelens
The two codelenses that are attached to the module statement are 'Run go mod tidy' and 'Create vendor directory'. In a 'go.mod' file without any required modules, the only codelens that shows up is the 'Create vendor directory'. With no required modules, there is nothing to vendor, but 'Run go mod tidy' may actually clean up the go.mod and go.sum, so this is the codelens we want to appear. Change-Id: I7264f8c4c4427a66264684f71fd4407b2170609f Reviewed-on: https://go-review.googlesource.com/c/tools/+/322292 Trust: Suzy Mueller <suzmue@golang.org> Run-TryBot: Suzy Mueller <suzmue@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
88a9bccae5
commit
d5449c00d2
|
|
@ -81,10 +81,6 @@ func tidyLens(ctx context.Context, snapshot source.Snapshot, fh source.FileHandl
|
|||
if err != nil || pm.File == nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(pm.File.Require) == 0 {
|
||||
// Nothing to vendor.
|
||||
return nil, nil
|
||||
}
|
||||
uri := protocol.URIFromSpanURI(fh.URI())
|
||||
cmd, err := command.NewTidyCommand("Run go mod tidy", command.URIArgs{URIs: []protocol.DocumentURI{uri}})
|
||||
if err != nil {
|
||||
|
|
@ -105,6 +101,10 @@ func vendorLens(ctx context.Context, snapshot source.Snapshot, fh source.FileHan
|
|||
if err != nil || pm.File == nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(pm.File.Require) == 0 {
|
||||
// Nothing to vendor.
|
||||
return nil, nil
|
||||
}
|
||||
rng, err := moduleStmtRange(fh, pm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue