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/internal/imports: fails with empty file on disk #39315
Comments
Change https://golang.org/cl/235581 mentions this issue: |
This test partially reproduces some strange behavior with creating new tests files. In particular, it creates a new x test in a package that already has a test variant and adds content with a missing import. In the test, the import is never added. However, in my own experience debugging this in VS Code, I see the import get added but the diagnostic never get removed. One thing at a time though... Updates golang/go#39315 Change-Id: I724a145688b915d04abd1f21efc6f9a7506be043 Reviewed-on: https://go-review.googlesource.com/c/tools/+/235581 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
@heschik noted that the regression test doesn't appear to run any code actions. However, the log does contain code actions, just slightly out-of-order:
The @heschik, do you see this behavior? /cc @findleyr |
Boy did I overthink this. goimports gives up on a directory if there's a parse error, and your empty file with no package statement causes a parse error. Easy fix if you care. |
I do, because if someone creates a new file and doesn't save it for whatever reason, they won't get |
Change https://golang.org/cl/237686 mentions this issue: |
The repro case for this issue can be found in a
gopls
regression test in https://golang.org/cl/235581.I have noticed that when the file is empty on disk, but the source provided includes content with a missing import, the
goimports
behavior will not succeed. Similarly, if the file has content on disk, but is empty in the overlay, an import will be added (this looks very bizarre in the editor)./cc @heschik
The text was updated successfully, but these errors were encountered: