Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: changing environment variables can cause gopls to forget file content #57934

Closed
findleyr opened this issue Jan 20, 2023 · 2 comments
Assignees
Labels
gopls/corruption Issues related to file corruption in gopls gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

Just noticed that gopls' internal view of the filesystem relies on seeing every change since the LSP session started (see also #57558).

But this breaks if we reinitialize state following a major change to settings. This can cause gopls to get confused about the content of open files. I have reproduced in a test, and have a fix.

I think this has been the behavior since ~always, and may be a cause of users reporting having to restart gopls following configuration changes in VS Code.

@findleyr findleyr added NeedsFix The path to resolution is known, but the work has not been done. gopls/corruption Issues related to file corruption in gopls labels Jan 20, 2023
@findleyr findleyr added this to the gopls/v0.12.0 milestone Jan 20, 2023
@findleyr findleyr self-assigned this Jan 20, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jan 20, 2023
@gopherbot
Copy link

Change https://go.dev/cl/462821 mentions this issue: gopls/internal/regtest: add a test demonstrating confusion following an

gopherbot pushed a commit to golang/tools that referenced this issue Jan 23, 2023
options change

Add a test that demonstrates gopls gets confused about file content
following an options change.

For golang/go#57934

Change-Id: I536245877ef9069613d6e551354b00fc42b3bc5c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/462821
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
@findleyr findleyr modified the milestones: gopls/v0.12.0, gopls/v0.13.0 Mar 30, 2023
@findleyr findleyr modified the milestones: gopls/v0.13.0, gopls/v0.12.0 May 22, 2023
@gopherbot
Copy link

Change https://go.dev/cl/496883 mentions this issue: gopls/internal/regtest/misc: unskip TestMajorOptionsChange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/corruption Issues related to file corruption in gopls gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants