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: surface a diagnostic when opening a file with a DO NOT EDIT comment #33397

Closed
kennytm opened this issue Aug 1, 2019 · 10 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@kennytm
Copy link

kennytm commented Aug 1, 2019

Migrated from microsoft/vscode-go#2617.

When opening a file containing this comment anywhere

^// Code generated .* DO NOT EDIT\.$

it should send a diagnostic, so that the LSP client can display a prominent warning to prevent accidental editting.

@gopherbot gopherbot added this to the Unreleased milestone Aug 1, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 1, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: Send a diagnostic when opening a file with a DO NOT EDIT comment x/tools/gopls: surface a diagnostic when opening a file with a DO NOT EDIT comment Aug 2, 2019
@gopherbot
Copy link

Change https://golang.org/cl/188766 mentions this issue: internal/lsp: do not show diagnostics for generated files

@vincepri
Copy link

Is there a way to disable this warning? Running gopls from master, vscode spams notifications.

@stamblerre
Copy link
Contributor

By spams, do you mean that more than one notification is being sent?

@vincepri
Copy link

That's correct. It seems it happens very frequently when vscode auto-saves on focus or after a timeout, even if I'm just reading the file 😄

@stamblerre
Copy link
Contributor

gopls should only show this message once - when you open the file for the first time in VSCode. I believe that VSCode-Go itself may also send its own similar diagnostic message and perhaps there is a duplicate there. Do you mind sharing a screenshot?

@vincepri
Copy link

It seems that these only come from gopls, given that the dropdown doesn't have the option to suppress the warning. On a deeper look it seems that this happens when I'm browsing through different generated files. It'd be great to have an option to remove it though, it seems that's not possible today. WDYT?

Screen Shot 2019-08-12 at 3 19 14 PM

@stamblerre
Copy link
Contributor

Thanks for sharing. One thing I could do is change this diagnostic so that it appears only if a user tries to edit the file, rather than on open.

@vincepri
Copy link

That sounds great! I can report back when that change goes on master :)

@stamblerre
Copy link
Contributor

@vincepri: Just submitted the change. Sorry about the delay!

@vincepri
Copy link

@stamblerre 24h is more than amazing! :D Thank you so much for working on it! I can confirm it's working as expected 😍 🎉

@golang golang locked and limited conversation to collaborators Aug 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

4 participants