-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Completion sorting ignores sortText from completion items when typing #79516
Comments
(Experimental duplicate detection) |
(I found #64367, but that seems more about filtering than sorting?) |
Please ask your question on StackOverflow. We have a great community over there. They have already answered thousands of questions and are happy to answer yours as well. See also our issue reporting guidelines. Happy Coding! |
The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines. Happy Coding! |
An extension can define the initial order with |
@jrieken does this mean there's no way to override it, and it won't be considered? The example given above is a bad user experience (and leads to bugs being raised) - it seems silly not to consider an option to control this. Also - out of interest - the IntelliCode extension claims to do intelligent sorting of completions - does that also only apply when there's no prefix? |
This behaviour is very limiting as the overruled results are completely irrelevant. When passing the value of an enum, I would much rather have the enum values completed than the |
Yes. However, if find cases in which the scorer selects the wrong item or ranks badly then feel free to file issues. In above sample suggestions like |
That's not true if you have the context that the language server has. The language server knows that's n argument and its type is VS Code doesn't have anywhere near as much context as the language server so having it override the results the server came up with with simple text-based heuristics that don't understand the language will always be sub-optimal to a good language server. What's the reason this couldn't be controlled by an option (either for the user, or the completion provider)? |
I agree that the language server has most context but this is about enabling users to pick any suggestion. Assuming I do want to insert Resorting items based on user input isn't a critic to the language server but helping the user to insert the suggestion she/he wants to select. I understand that from your point of view it should be the absolute best suggestion but you have to accept users choosing different (or not make that suggestion to begin with). The selection/resorting is based on an algorithm which, amongst other things, favours matches at the beginning of words over matches at the end. I think that's a fair assumption because words are usually typed from 'start to end' (and not 'end to start'). |
If the parameter is an enum and the |
Did you try that? You should be able to type
Matches on upper-case characters and after separate characters ( Last, if you think no-one ever types |
In this specific case, yes - it would definitely be the best UX. Because the language server knows that the chance of that case is almost 0 and the case of the other is almost 100% because it has context. The language server has done hard work to provide contextual-relevant results but VS code is overriding them with naive text-based heuristics.
But VS Code doesn't have all the information to make the best call, as is shown here. If VS Code wants to do the sorting, then it should allow servers to provide it more information to make a better decision. If I change Out of interest - how does IntelliCode work? Does it suffer from the same issue, or does it have some ability to mark preferred completions that we don't have? |
Not only does it not work, it puts
I mentioned that above, but that removes the ability for a user to type the enum name to see all the values if they don't know what they are (and that's even worse UX). |
Typing |
Sorry, you don't understand what I am saying. This is not about VS Code but about users having the freedom to select the suggestions you are making. Don't make bad suggestions if you don't want them to be inserted.
There is no difference. They use
I have filed #79558 for that. |
Freedom? What freedom? A list is shown anyway. This is about the language server saying "here's what they 99% meant" and VS Code saying "nope, they actually meant this because |
This isn't about good and bad suggestions though, it's about "very relevant" and "not so relevant". We shouldn't exclude entries from completion just because they're very unlikely if they could still be valid (although
In their examples, the ones with the stars all appear at the top (it's possible the example gif isn't showing the whole picture though). Are they all set as preselect? If not, how do they all stay at the top?
Thanks - based on the text there it sounds like you already have a concept of a separator. Given that, couldn't you weight |
To give my |
@gjsjohnmurray does that actually work here? I see VS Code doing the same magic if I force completion open with Ctrl+Space after typing the prefix (so it's hitting my provider), but it still seems to re-sort them based on the prefix it sees in the doc, rather than one that was typed since opening the completion list. |
@DanTup I've certainly found |
It's definitely useful, but I don't think it helps here. I tried enabling it but it made no difference. @jrieken I just noticed that just typing |
Yeah, that because |
|
@jrieken not sure this warrants its own issue if it's expected, but here's another place I think the ranking is bad: I think things that have "end" as concurrent characters (and in exact matched case) should come above things that have |
Any updates on this? Any change of mind? There seems to be a tradition for VS Code to think it's smarter than the language server and mess things up, creating a bad user experience. Time to move to JetBrains. |
It seems like there have been some issues around this before, but I can't find any conclusive description that this is by design (though there's a comment from @jrieken at #71660 (comment) suggesting there may be internal ranking going on that can't currently be disabled, but I can't find the related case to see if it's been addressed yet). I've tried all of the "suggest" config options I can find, but I can't find a way to disable this.
Here's what my completion item provider is returning:
And when I invoke completion, the list sorted as expected:
However, when the user types
min
, VS Code does its own sorting, and the values the user is interested in (which we've ranked highest according to sort order) move right down the list:I appreciate VS Code is trying to be helpful, but here it's magic is making things significantly worse. Is there some way to influence this (either as a user, or an extension author) that I've overlooked, or is this currently the expected behaviour?
(Raised at Dart-Code/Dart-Code#1934 by @dancojocaru2000)
The text was updated successfully, but these errors were encountered: