Skip to content

Commit

Permalink
gopls/internal/lsp/source: make "chatty" diagnostics the default
Browse files Browse the repository at this point in the history
This CL changes the default behavior of gopls to always publish
diagnostics for new file versions. In practice, this avoids stale
diagnostics in multiple LSP clients (golang/go#54983 has more details).

After this change, TestDownloadDeps was failing because it asserted on
the non-existence of published diagnostics. Update the test to treat an
empty diagnostic set the same as an unreceived diagnostic set.

Fixes golang/go#54983

Change-Id: I41ed2f859b748e14585e7feb53702d3f38dcd599
Reviewed-on: https://go-review.googlesource.com/c/tools/+/429935
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr committed Sep 12, 2022
1 parent 7e129ca commit ec74389
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions gopls/internal/lsp/source/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func DefaultOptions() *Options {
CompleteUnimported: true,
CompletionDocumentation: true,
DeepCompletion: true,
ChattyDiagnostics: true,
},
Hooks: Hooks{
ComputeEdits: myers.ComputeEdits,
Expand Down Expand Up @@ -587,11 +588,6 @@ type InternalOptions struct {
// ChattyDiagnostics controls whether to report file diagnostics for each
// file change. If unset, gopls only reports diagnostics when they change, or
// when a file is opened or closed.
//
// TODO(rfindley): is seems that for many clients this should be true by
// default. For example, coc.nvim seems to get confused if diagnostics are
// not re-published. Switch the default to true after some period of internal
// testing.
ChattyDiagnostics bool
}

Expand Down Expand Up @@ -824,7 +820,6 @@ func (o *Options) EnableAllExperiments() {
o.ExperimentalUseInvalidMetadata = true
o.ExperimentalWatchedFileDelay = 50 * time.Millisecond
o.NewDiff = "checked"
o.ChattyDiagnostics = true
}

func (o *Options) enableAllExperimentMaps() {
Expand Down
4 changes: 2 additions & 2 deletions gopls/internal/regtest/modfile/modfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,8 @@ func main() {
)
env.ApplyQuickFixes("main.go", d.Diagnostics)
env.Await(
EmptyDiagnostics("main.go"),
NoDiagnostics("go.mod"),
EmptyOrNoDiagnostics("main.go"),
EmptyOrNoDiagnostics("go.mod"),
)
})
}
Expand Down

0 comments on commit ec74389

Please sign in to comment.