Skip to content

Commit

Permalink
internal/lsp: don't search for workspace modules by default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stamblerre committed Sep 24, 2020
1 parent 7bb30d1 commit 04afef3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/lsp/cache/session.go
Expand Up @@ -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,
Expand Down

0 comments on commit 04afef3

Please sign in to comment.