internal/lsp: don't search for workspace modules by default

This may be expensive, and we don't want to do it if the results will
be unused.

Updates golang/go#41558

Change-Id: I0c01a80f4fc459e1cc189934ad23ab443e5ea2a5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/257137
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Rebecca Stambler 2020-09-24 12:15:35 -04:00
parent 7bb30d1408
commit 04afef382b
1 changed files with 8 additions and 4 deletions

View File

@ -166,10 +166,14 @@ func (s *Session) createView(ctx context.Context, name string, folder span.URI,
return nil, nil, func() {}, err
}
// Find all of the modules in the workspace.
modules, err := findWorkspaceModules(ctx, ws.rootURI, options)
if err != nil {
return nil, nil, func() {}, err
// If workspace module mode is enabled, find all of the modules in the
// workspace.
var modules map[span.URI]*moduleRoot
if options.ExperimentalWorkspaceModule {
modules, err = findWorkspaceModules(ctx, ws.rootURI, options)
if err != nil {
return nil, nil, func() {}, err
}
}
// Now that we have set all required fields,