-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Implement server-side completion sorting and filtering #7935
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
I was thinking on making a few benchmarks and maybe a few more path-handling improvements before even starting to think about this myself. Should we also close #4544 ? |
#7945 refactors some code, renaming CompletionScore to Relevance |
Thanks for writing this up! I'll give this a shot 👍 It seems #7945 doesn't change that we don't sort I think long term we plan to be setting the value for In stage 1 we could be building out lots of Then stage 2 would be filtering, where we'd do fuzzy matching and have to deal with the Does this seem feasible? |
Yeah, I think that might make sense. I haven’t looked closely into that PR,
but, if it works better in vs code than what we have today, I think we
should merge.
…On Tuesday, 9 March 2021, Josh Mcguigan ***@***.***> wrote:
Thanks for writing this up! I'll give this a shot 👍
It seems #7945 <#7945>
doesn't change that we don't sort type+name matches above just type
matches. In the short term, is there a downside to taking the approach I
proposed in #7904
<#7904>, which is to
set the sortText for all items to some value [1, 3]?
I think long term we plan to be setting the value for sortText for all
items anyway. So I think my question is partly, can this work be rolled out
to users in stages, where stage 1 is the sorting and stage 2 is the
filtering.
In stage 1 we could be building out lots of Relevance criteria, and it
would be nice if during stage 1 we were setting sortText in such a way
that users could see the improved sorting right away.
Then stage 2 would be filtering, where we'd do fuzzy matching and have to
deal with the LSP Hacking you've described above (I'm still reading
through the github issue linked there). Basically I can see the fuzzy
matching and lsp hacking bringing on a whole other set of challenges, and
it would be nice if we could avoid blocking the benefits of stage 1 behind
the release of stage 2.
Does this seem feasible?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#7935 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANB3M43I3FAJYOPHFSXEKDTCZ3AXANCNFSM4Y3RWYNQ>
.
|
8014: increase completion relevance for items in local scope r=matklad a=JoshMcguigan This PR provides a small completion relevance score bonus for items in local scope. The changes here are relatively minimal, since `coc` by default pre-sorts by position in file. But as we move toward fully server side sorting #7935 I think we'll want some relevance score bump for items in local scope. ### Before Note `let~` and `syntax` are both ahead of locals. Ultimately we may decide that `let~` is a high relevance completion given my cursor position here, but that should be done with some explicit scoring on the server side, rather than being caused by (I think) `coc` preferring shorter completions.  ### After  Co-authored-by: Josh Mcguigan <[email protected]>
See #7686 for an example of less than ideal sorting. |
7992: improved completion sorting for functions and methods r=JoshMcguigan a=JoshMcguigan This PR improves completion sorting for functions and methods. Related to #7935. ### Before The methods are being sorted by `coc` by closeness in file.  ### After Notice `bbb()` on top (type + name match), followed by `ddd()` (type match).  Co-authored-by: Josh Mcguigan <[email protected]>
clangd has this: https://clangd.llvm.org/extensions.html#code-completion-scores |
Triage: We now have a |
I think the crucial think we still don't do is the fuzzy matching of what the user has typed with the identifier we want to complete. That is, I belive current scorring completley ignores edit distance (double check me). Makes sense to open a separate issue for that maybe? |
#13124 shows an interesting use-case for this: sometimes (bindgen mostly) the amount of symbols we want to complete is humongous, which actually creates performance problems. So, ideally, we include a pre-filtering step: not only we want to sort & cull completions after we build the whole list, but, even while we are producing completions, we should keep only the 1000s best according to fuzzy matching (computing just the label for fuzzy matching is much cheaper than rendering the whole completion item). |
At the moment, we rely entirely on client-side sorting of completions. That's bad, and we should implement server side sorting. The big steps here are:
Design
Each completion item should have a
CompletionScore
object. Scores are partially comparable. Score should record, precisely why we think this variant may be better than average and should return facts like "do the types align exactly?", "are we looking for a non-static function here", etc. I think it should be a bunch of bools. It currently isI don't think that's the right repr.
After scores, we should implement fuzzy matching. We should look at the identifier being completed, and comput, for each
CompletionItem
, how good the match is, throwing away the completions which are not relevant.Then, we should sort the final list, taking into account both the fuzzy score and CompletionScore (does it need a better name? MatchBits?)
Implementation
Fuzzy scoring needs to be implemented from scratch I think. Scores are partially there
LSP Hacking
LSP actually insists that the client does sorting&filtering, so we need to hack around that, see microsoft/language-server-protocol#898 for details. I believe we need to:
isIncomplete
totrue
format!("{04}", i)
wherei
is our final orderPolishing
We produce a ton of garbage completions at the moment, so we should take care to actually design and use the appropriate scores.
The text was updated successfully, but these errors were encountered: