Skip to content

Commit 8849913

Browse files
committed
internal/lsp: be more careful about showing workspace misconfig message
We can re-enable this when we have a version of Go that includes the fix for golang/go#37971. Then we can continue playing whack-a-mole with go list corner cases :) Fixes golang/go#37958 Change-Id: I2417731bf5c01fbde867fef2ef03b5025ae779c7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/224538 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent e609210 commit 8849913

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

internal/lsp/diagnostics.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,21 @@ func (s *Server) diagnose(ctx context.Context, snapshot source.Snapshot, alwaysA
8585
if ctx.Err() != nil {
8686
return nil
8787
}
88+
// If we encounter a genuine error when getting workspace packages,
89+
// notify the user that their workspace may be misconfigured.
8890
if err != nil {
89-
// If we encounter a genuine error when getting workspace packages,
90-
// notify the user.
91-
s.showedInitialErrorMu.Lock()
92-
if !s.showedInitialError {
93-
err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
94-
Type: protocol.Error,
95-
Message: fmt.Sprintf("Your workspace is misconfigured: %s. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.", err.Error()),
96-
})
97-
s.showedInitialError = err == nil
91+
// TODO(golang/go#37971): Remove this guard.
92+
if !snapshot.View().ValidBuildConfiguration() {
93+
s.showedInitialErrorMu.Lock()
94+
if !s.showedInitialError {
95+
err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
96+
Type: protocol.Error,
97+
Message: fmt.Sprintf("Your workspace is misconfigured: %s. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.", err.Error()),
98+
})
99+
s.showedInitialError = err == nil
100+
}
101+
s.showedInitialErrorMu.Unlock()
98102
}
99-
s.showedInitialErrorMu.Unlock()
100-
101103
event.Error(ctx, "diagnose: no workspace packages", err, tag.Snapshot.Of(snapshot.ID()), tag.Directory.Of(snapshot.View().Folder))
102104
return nil
103105
}

0 commit comments

Comments
 (0)