-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: improve UX with unimported completions and -mod=readonly #43339
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
Comments
This is roughly the same scenario I mentioned when discussing automatically accepting changes to |
IMO, the fixes needed here are to (1) show the diagnostic on the unsaved file (and figure out why it's not showing up), and (2) to make sure that unimported completions work even if the module has not yet been added to the |
Change https://golang.org/cl/280095 mentions this issue: |
I'm not able to reproduce this simply in the playground so this may take some more investigation: https://play.golang.org/p/7NupO_XLpKX. |
My mistake--it actually is reproducible with a simple example: https://play.golang.org/p/j5y5HtJ8Afm. Looks like this is WAI. |
The new -mod=readonly changes have affected the behavior of unimported completions, leading to some strange behavior. Here's an example of the problem:
go.mod
file of the module.main.go
file and start typinggoldmark
. You will see a completion forgoldmark
suggested..
to trigger a subsequent completion.See no results because the new package has not yet been added to the
go.mod
file. However, no diagnostic is shown on the import because the file is still unsaved.Typing any characters, even if they are incorrect, will cause the diagnostic to show up.
Also, note that
goimports
works fine without the require in thego.mod
file, but unimported completions fail in the specific case of an accepted unimported package completion followed by a.
-- saving the file as-is causes the diagnostic to appear, but it does not cause unimported completions to appear./cc @findleyr @heschik
The text was updated successfully, but these errors were encountered: