-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
A number of VSCode issues have been raised regarding problems with formatting (see microsoft/vscode-go#2824, microsoft/vscode-go#2787). There are a few possibilities about what the source of this issue might be, but it is likely that either, (1) formatting is being run on old code, or (2) something is going wrong with the diff algorithm.
If you have this issue, please share the following information so that we can diagnose it:
- Your VSCode settings (
Ctrl + Shift + P
->Preferences: Open Settings (JSON)
) - Your
gopls
version (gopls version
) - The output of
gopls -rpc.trace -v format path/to/file.go
- Your
gopls
logs from when this issue occurs (see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs for information on how to capture logs).
Furthermore, we have recently substituted the gopls
diff algorithm for a better alternative. It's possible that this was the culprit. If you are able to install gopls
at master:
$ GO111MODULE=on go get golang.org/x/tools/gopls@master golang.org/x/tools@master
then you can try out this new diff algorithm. Try it by adding the following setting:
"gopls": {
"go-diff": true
}
If any users test out go-diff
, please do report if this changes anything.
Finally, it will be helpful to determine if the issue is formatting or imports. Please try disabling the following settings one at a time and please report which alters the behavior.
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
}