-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: completion incorrectly offers embedded field shadowed by outer field #60069
Comments
Thanks for the report. You're right that this is inaccurate. We should instead offer the deep completion of v.inner.logger. |
I'm not clear that in this case you should. Because I don't have deep completions turned on (intentionally), and hopefully my config reflects that. |
@myitcv yes, I mean only in the case where deep completions are enabled. |
BTW: @myitcv I'm curious why you have deep completions turned off, if you don't mind providing feedback. |
Of course! Please bear in mind that what follows is largely a function of my personal experience and preference using Vim. I have deep completions turned off for largely the same reason as I'm advocating for search scopes in #37237. 90% of the time I don't want deep completions. So any results that are deep would be noise, and I find that noise incredibly distracting. If I could have a keystroke to opt a particular completion into deep completion I would take that for sure! But much like different search scopes, I don't want the default to be "I'll include everything and you keep typing to be more precise". In both cases, I know the scope of the completion or the search, and am happy to assign a key binding to change the scope. So all or nothing config options don't work for me. |
Thanks! I think proper sorting can come close to providing the best of both worlds. Gopls could improve a lot in this regard. |
I'm not entirely sure I understand what you mean by "proper sorting". Not least because I'm not clear that in this or the the symbol case "proper sorting" (or indeed any ranking algorithm) can ever know the intended scope of my completion/search, and therefore segment the results accordingly. Per #37236 (comment), the visual noise is, in any case, a major part of the problem for me. |
I don't see duplicate "logger" candidates anymore, but I still don't see "inner.logger" with deep completions enabled. I think there is some code somewhere that assumes embedded structs don't need to be searched because their fields were already included in the containing struct's fields, but that is not true for fields with conflicting names. |
Change https://go.dev/cl/592975 mentions this issue: |
Change https://go.dev/cl/594242 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
With the following input file:
The cursor at the position
_
.Attempt a completion.
What did you expect to see?
The single candidate
outer.logger
.What did you see instead?
Two candidates:
The completion text for both is the plain
logger
. So this can't be correct, as theouter.logger
shadows the embeddedinner.logger
.The text was updated successfully, but these errors were encountered: