-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: improve unimported completion ranking #38104
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
The goimports code makes no attempt to return a consistent set of results, so some randomness is expected when there are many candidates with equal prioritization. But these don't have equal priorities. The problem is that when it scans the disk, it scans in priority order. But the cache iteration is in a random order, and gopls cancels the iteration as soon as it gets some number of results. There's currently no attempt to keep receiving results until it gets them at a high enough priority. I'm not sure what to do about this; the cache can't know priorities because it's not dependent on the I'm not sure what to do about this. |
Is there a way to change the cache iteration order? Or to at least have it prefer the local module? It seems to me you're much more likely to be looking for a package in your module. |
Forgot a trick, mailed https://golang.org/cl/226559 which should improve things significantly. We can revisit if there's more complaints. I can't think of any more quick fixes. Haven't looked at the |
With current For example, we use As for autocompletion, if I just type Why can't the import reorg simply check each candidate against |
The imports-on-save path doesn't rank by module relevance; that's #36077. If you already use testify in your project, it should be at the top of the rankings, because it should be in memory. I think the behavior in your screencast is simply be a scoring bug -- untyped completions are ending up before typed completions, which really shouldn't happen. @muirdm might have a guess here. I can try to reproduce it at some point, it might be pretty easy, but I don't have time right now.
In general the answer to any question of the form "why can't X just Y" is going to be that it's harder than you think it is. I went into some detail above. If you want a full explanation of the architecture of the autocomplete feature, I would appreciate you asking more politely. |
I looked briefly and all unimported packages seem to have a relevance of 3, which is the lowest score. github.com/stretchr/testify/assert should have a relevance of 6 if it is a direct dependency of the main module. |
Change https://golang.org/cl/231238 mentions this issue: |
The CL above didn't fix Rebecca's issue, but I don't want to leave this open as a magnet for every ranking complaint, so I'm inclined to leave it closed for now. |
Oops. I was working off @atombender's comment which I now realize does not overlap with the original items in this issue. I think the other unimported package issue you were working on should fix
All completion results are marked as incomplete if you have deep completions or fuzzy matching enabled. Not sure what was going on here. Do you have the rpc trace? |
Apologies. It's often hard to know some behaviour is the same issue. My own completion problem sounded to me like what this issue described. |
I recently noticed a few issues with unimported completion:
It doesn't seem to be prioritizing packages in my module above packages in my module cache. In this case, I wanted to import golang.org/x/tools/internal/gocommand, but I got suggested github.com/govim/govim but not
gocommand
.We should mark completion results with unimported completions in them incomplete (I thought we already did?). VS Code did not trigger completion again as I typed, resulting in this:
/cc @heschik @muirdm
The text was updated successfully, but these errors were encountered: