-
Notifications
You must be signed in to change notification settings - Fork 767
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
Format on save for Go source files doesn't respect editor.formatOnSave setting #1815
Comments
Can you please share your The setting works by not sending formatting requests to the extension when formatOnSave is disabled, so if there is a bug here, it would be a VS Code bug, not a Go extension bug. |
Thanks for your speedy response!
The bug exists whether with gopls enabled or disabled.
The following was observed with the following VSCode setting:
Click to expandI've redacted paths; but you should get the idea...
|
Thanks for sharing this log. Looks like the |
I'm happy to file an issue against vscode, though it would be good to rule out vscode-go first. Are you able to reproduce, with and without gopls enabled? (The bug is present with both here.) |
Yeah, I actually did repro. I think it's because the VS Code Go extension defaults to formatOnSave being enabled: Line 184 in 9b3e92e
|
Thanks for that line reference; with it I was able to find #65844 and #58995 which refer to the same problem for a variety of VSC-supported languages and associated settings. The "official" method to control the format-on-save, or any of the other settings under Given that #58995 is almost three years old and it may not get addressed any time soon, is there any way to flip this issue into a documentation change, or a hack in the vscode-go settings panel to educate the user so they don't end up following the same path of confusion as I did? |
My understanding is that the language-specific configuration overrides non-language-specific configuration setting (https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration) so this is working as expected from VSCode's point of view even though surfacing these to users (microsoft/vscode#58995) definitely needs improvement. This is not the first time this language-specific default override caused confusion. Some users request basically not to set language-specific defaults but stay away from If we want to turn this into a documentation change, where is the best place to surface this info? The Popup to suggest the best practice setting instead of Any idea to improve documentation is welcome. |
"source.organizeImports" has some weird behavior if there are no imports (formatting the whole file). Would this be the root cause or similar? Here's a short video. |
@mukunda- Thanks for the report. It sounds like that is a different issue because you have all the per-language settings override. Can you please file a separate issue with a smaller repro case and the gopls trace (instruction)? Thanks! |
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>
Change https://go.dev/cl/412383 mentions this issue: |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.Run
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.7f6ab5485bbc008386c4386d08766667e155244e
x64
Check your installed extensions to get the version of the VS Code Go extension
Describe the bug
editor.formatOnSave
setting, vscode-go still formats Go files on save.editor.formatOnSave
setting, as the workaround above must be set up by editing the VSC settings json file; it is not selectable via the GUI settings panel.The text was updated successfully, but these errors were encountered: