Skip to content

Commit

Permalink
internal/lsp: correct links provided in critical error pop-ups
Browse files Browse the repository at this point in the history
Fixes golang/go#43600

Change-Id: Ib36b832652d20b542a3065544d41fee1f2ae3172
Reviewed-on: https://go-review.googlesource.com/c/tools/+/285515
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: Heschi Kreinick <heschi@google.com>
  • Loading branch information
stamblerre committed Jan 22, 2021
1 parent e13398c commit 2972602
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions gopls/doc/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ contain that single module. Otherwise, you are working with multiple modules.

### Multiple modules

As of Jan 2020, if you are working with multiple modules, you will need to
create a "workspace folder" for each module. This means that each module has
its own scope, and features will not work across modules. We are currently
working on addressing this limitation--see details about
As of Jan 2021, if you are working with multiple modules or nested modules, you
will need to create a "workspace folder" for each module. This means that each
module has its own scope, and features will not work across modules. We are
currently working on addressing this limitation--see details about
[experimental workspace module mode](#experimental-workspace-module-mode)
below.

Expand Down
10 changes: 6 additions & 4 deletions internal/lsp/cache/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ func (s *snapshot) workspaceLayoutError(ctx context.Context) *source.CriticalErr
if !s.ValidBuildConfiguration() {
msg := `gopls requires a module at the root of your workspace.
You can work with multiple modules by opening each one as a workspace folder.
Improvements to this workflow will be coming soon (https://github.com/golang/go/issues/32394),
and you can learn more here: https://github.com/golang/go/issues/36899.`
Improvements to this workflow will be coming soon, and you can learn more here:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.`
return &source.CriticalError{
MainError: errors.Errorf(msg),
ErrorList: s.applyCriticalErrorToFiles(ctx, msg, openFiles),
Expand Down Expand Up @@ -236,13 +236,15 @@ and you can learn more here: https://github.com/golang/go/issues/36899.`
msg := fmt.Sprintf(`This file is in %s, which is a nested module in the %s module.
gopls currently requires one module per workspace folder.
Please open %s as a separate workspace folder.
You can learn more here: https://github.com/golang/go/issues/36899.
You can learn more here: https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.
`, modDir, filepath.Dir(rootModURI.Filename()), modDir)
srcErrs = append(srcErrs, s.applyCriticalErrorToFiles(ctx, msg, uris)...)
}
if len(srcErrs) != 0 {
return &source.CriticalError{
MainError: errors.Errorf(`You are working in a nested module. Please open it as a separate workspace folder.`),
MainError: errors.Errorf(`You are working in a nested module.
Please open it as a separate workspace folder. Learn more:
https://github.com/golang/tools/blob/master/gopls/doc/workspace.md.`),
ErrorList: srcErrs,
}
}
Expand Down

0 comments on commit 2972602

Please sign in to comment.