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
Closed
Labels
Milestone

Comments

@kennytm
Copy link

@kennytm 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 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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 2, 2019

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

@vincepri

This comment has been minimized.

Copy link

@vincepri vincepri commented Aug 12, 2019

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

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Aug 12, 2019

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

@vincepri

This comment has been minimized.

Copy link

@vincepri vincepri commented Aug 12, 2019

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

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Aug 12, 2019

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

This comment has been minimized.

Copy link

@vincepri vincepri commented Aug 12, 2019

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

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Aug 12, 2019

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

This comment has been minimized.

Copy link

@vincepri vincepri commented Aug 12, 2019

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

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Aug 13, 2019

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

@vincepri

This comment has been minimized.

Copy link

@vincepri vincepri commented Aug 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.