Skip to content

Commit

Permalink
internal/lsp: update diagnostic snapshotID even if not published
Browse files Browse the repository at this point in the history
The LSP server tracks the snapshot ID for which diagnostics were last
published, but this ID was not being updated if the publish was
suppressed when there are no changes, which can cause incorrect
diagnostics when snapshots are published out-of-order (a separate bug).

Fix this to update the snapshot ID when the current published
diagnostics match the latest computed diagnostics.

Fixes golang/go#42837

Change-Id: I3634e6f351a479aefa5c9423956720431590d814
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275238
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
  • Loading branch information
findleyr committed Dec 4, 2020
1 parent 3949734 commit 214da9f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/lsp/diagnostics.go
Expand Up @@ -485,6 +485,9 @@ func (s *Server) publishDiagnostics(ctx context.Context, final bool, snapshot so
source.SortDiagnostics(diags)
hash := hashDiagnostics(diags...)
if hash == r.publishedHash {
// Update snapshotID to be the latest snapshot for which this diagnostic
// hash is valid.
r.snapshotID = snapshot.ID()
continue
}
version := float64(0)
Expand Down

0 comments on commit 214da9f

Please sign in to comment.