-
Notifications
You must be signed in to change notification settings - Fork 768
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
Go extension formats files without imports even if formatOnSave is false #2268
Comments
Hi, I can't repro this, though I may be misunderstanding. Per https://github.com/golang/vscode-go/wiki/advanced, the correct way to disable auto-formatting is as follows:
(which you have done) When I do this, I don't get any formatting. Do you have any other settings (e.g. do you have |
And add back the title that was dropped by accident. Updates golang#2268 Updates golang#1815 Updates golang#1805 Change-Id: Iea464b1e54f0eb5d421d28c7bea40a86e49dc517
And add back the title that was dropped by accident. Updates golang#2268 Updates golang#1815 Updates golang#1805 Change-Id: Iea464b1e54f0eb5d421d28c7bea40a86e49dc517
Change https://go.dev/cl/412054 mentions this issue: |
And add back the title that was dropped by accident. Updates #2268 Updates #1815 Updates #1805 Change-Id: Iea464b1e54f0eb5d421d28c7bea40a86e49dc517 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/412054 Reviewed-by: Jamal Carvalho <jamal@golang.org>
Sorry I completely missed your reply but I don't have any other settings. The file you're saving must have no imports, meaning that you shouldn't use any modules, otherwise it works as intended. Are you sure you tried to save a go file without any imports? |
Do you mean you do not have @findleyr I could reproduce the issue with |
No, I do have a go.mod file. What I meant was no module/package used in the specific file you're saving (basically just no imports for that file). I didn't change any go settings. You guys did my 5 steps exactly, with formatOnSave false, and couldn't reproduce? |
Can you help me find what I did differently? (the first part is when formatOnSave is false, the second part is when formatOnSave is true) |
It seems like it's working correctly on your end for some reason. Mine is formatting even when false. Are you using a different formatter? My workaround for now is to disable gopls with "go.useLanguageServer": false, save my file and then re-enable it right after. I have to do that everytime I want to save a file without imports. |
No I don't use a different formatter. These are all my settings Preference : Open Settings (JSON)
Preference: Open Workspace Settings (JSON)
Can you capture the gopls log (from the beginning to the moment you get the formatting edits) with your minimal repro example and share the log? |
Change https://go.dev/cl/412383 mentions this issue: |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
Versions
go version go1.18.2 windows/amd64
gopls -v version golang.org/x/tools/gopls v0.8.4
code -v 1.67.2
go extension v0.33.1
Settings (user and workspace)
"editor.formatOnSave": false,
"[go]": {
"editor.formatOnSave": false
},
Describe the bug
Despite having my formatOnSave settings to false everywhere, the extension is formatting my go files that doesn't have imports.
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: