-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Typescript: sort auto-complete results by priority #47727
Comments
@jrieken Could typescript fix this by returning proper sortText? |
Yeah, set |
@mjbvz @jrieken I'd like to work on this, I just play a bit with the code and try to get the overall understanding of that part of the code. I've made some changes to wordDistance (I'm not sure what the responsibility of wordDistance is! I just want to get it work and see how the result would be). |
The wordDistance logic is new for the 1.28, see https://github.com/Microsoft/vscode-docs/blob/vnext/release-notes/v1_28.md#intellisense-locality-bonus. What changes did you have to make there, what is still missing? Generally, "yes" this is something TypeScript should get right but the locality bonus feature is now here to compensate for that. |
@jrieken Based on _compareCompletionItems conditions I just changed the distance of the local variables/Constants based on their kind to get them prioritised (definitely it's not a real solution). |
Btw, I'm wondering to ask if there is any issue regarding to sortText (^^) on TypeScript's repo. |
We already do that. The initial sort order is defined by the sortText-property and later carried on as |
|
@jrieken Do we need to do anything here at all? I'm confused! |
:-) yeah, I think with the locality bonus we are in a pretty good spot. having said that, it's pretty language agnostics by design and more or less works by looking at brackets only. TypeScript, having all the knowledge, will likely be better at computing those orders but lets see how far we get here |
I believe that microsoft/TypeScript#15024 is tracking this We're going to look into improving suggestion sort order with typescript 3.5. I'll link back to this issue so that we can take this feedback into account too |
The auto-completion feature for Typescript in VS Code usually makes the wrong guess - and it looks like the results are merely ordered alphabetically?
Example:
In this case (as most of the time) it is far more likely I want the nearest matching variable
connection
rather than the global (window
) methodconfirm
orconnect
.In PHP Storm or WebStorm, this works much better, and I've gotten used to typing extremely fast by relying heavily on it's ability to more accurately predict what I want after just two or three characters - I've learned to not even look at the auto-complete results before pressing TAB, and 95% of the time, it guesses exactly the thing I'm trying to type.
I think the Storm IDEs order the auto-complete results (in part) by vicinity?
That is, out of the results where the start of what I've typed matches, it orders those according to where I'm typing - variables in the closest scope to where I'm typing appear first, then variables in the parent scope, and so on, with results in the global scope being the least likely.
As a result, I'm learning not to trust auto-completion results, which is making me slower is Storm as well.
Could this be improved in VS Code, please?
The text was updated successfully, but these errors were encountered: