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: handle formatting on files that do not parse #31291
Comments
@stamblerre @ianthehat - should/can we also use this issue to pick up the conversation from https://go-review.googlesource.com/c/tools/+/171019/2#message-f8bec621217d3d2caad7dda408cdc629c71aaed6:
Or do you want to capture that discussion about error propagation elsewhere? |
I think that is a separate issue. In fact, is now issue #31526 |
This is a huge quality of life issue for me, and probably many others. Not being formatted makes it harder to fix errors so that the code can compile. This literally makes it harder and slower for me to code in Go. |
As a temporary workaround, we could shell out to the gofmt binary when a file has parse errors. |
Change https://golang.org/cl/187757 mentions this issue: |
Packages with errors may still contain files that can be formatted. Try to format the source of the files in packages that have errors. This change will still not format files with parse errors. Updates golang/go#31291 Change-Id: Ia5168d7908948d201eac7f2ee28534022a2d4eb0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/187757 Run-TryBot: Suzy Mueller <suzmue@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Change https://golang.org/cl/188767 mentions this issue: |
Updates golang/go#31291 Change-Id: Ibbd0b6cef9b9ec588c8a2e0c5e7ee6e3512b8a22 Reviewed-on: https://go-review.googlesource.com/c/tools/+/188767 Reviewed-by: Ian Cottrell <iancottrell@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org>
This issue should really be fixed in the |
If we don't check a package's parse errors before formatting, we may encounter a case where we delete code on format.
Repro:
To handle this, we check the parse errors before formatting. However, we should confirm that these errors belong to the file in question and lie within the specified range before failing.
The text was updated successfully, but these errors were encountered: