Open jacob314 opened 4 years ago
+100500. Smart autocompletion is a must have in 2021. Doesn't matter how "good" the typed language is itself, but if you can't get the right object into the right context fast with your IDE, better choose another language. (IMHO)
@DanTup would this be useful in VSCode as well?
I filed https://github.com/microsoft/vscode/issues/127516 about this but unfortunately it was closed as out-of-scope. I don't think we could make a good experience without it being built into VS Code (so you can easily flip between the type-filtered and complete lists).
I'm not sure what specifically is requested here.
Currently we already use the context type to give some suggestions more relevance, and put them higher.
Is there any something more requested here? It looks that the page changed since 4 years ago, and the link does not bring to any specific completion feature.
https://www.jetbrains.com/help/idea/auto-completing-code.html#smart_type_matching_completion is the updated link. I believe the idea is to make it easy to see only those things that match the type context.
I had an idea to support something like this in VS Code but I don't know what the experience would be like.. we could have an "Invoke Type-Filtered Completion" command that has its own shortcut key. It would ust set a flag which can be tagged onto the next completion request, then invoke completion. The server could use this flag to filter the results.
I haven't tried it out to see how it feels though - but if there's a lot of desire for this and VS Code won't built something in, maybe it's worth building a prototype to try out.
While I do think that this might be an interesting avenue to pursue, there might be better ways to improve the completion experience.
For example, there's been some discussion about making it easier to complete enum constants in argument lists by allowing them to be suggested when only the constant name is typed. (Maybe only when there's a prefix, in order to reduce the number of suggestions.) The net effect there would be to make it easier to type some of the most common matches for the context type without requiring the user to use a non-standard way of invoking code completion.
We could potentially expand this idea to include other static fields. For example, it might be very helpful for users to be able to type the name of a static field from Colors
without needing to type part of Colors
first.
As a side-note, a recent experiment suggested that we might currently be assigning too high a weight to suggestions that match the context type. I think we need to understand more about these results before we draw too many conclusions, but at the same time I think it would be good to understand these results before putting too much effort into supporting something like 'smart completion'.
They sound like good ideas, but they feel less general than this (for example they may only apply to statics/enum-likes whereas being able to filter the completion list by type might be helpful for other contexts).
I think there are some limitations we can't overcome from just changing things like ranking/filtering on the server alone:
a.b
where b
is the desired type and a
is not) and it doesn't show up, they would consider that a bugI think it would be good to understand these results before putting too much effort into supporting something like 'smart completion'.
Agreed - to be clear my idea of testing this out was to see how the idea of using a client-side VS Code command to invoke a "filtered" list of completion might feel in VS Code (even with hard-coded values). It's possible the experience would be awful and it wouldn't be worth persuring, and it wouldn't be difficult to try out (eg. hard-coded stuff just running from source locally).
They sound like good ideas, but they feel less general than this ...
That's true, they are.
What I was trying to explore was whether there might be an approach that would solve 80% of the cases without requiring users to learn a new interaction technique. If so, then I think it might be the better way to solve the problem.
That said, the two aren't mutually exclusive. If we solve the 80% case using the existing interactions and then need to introduce a new interaction technique in order to solve the remaining 20%, that would still be feasible.
https://www.jetbrains.com/help/idea/auto-completing-code.html#smart_completion Smart code completion filters the suggestions list and shows only the types applicable to the current context.
This would be helpful for named parameters of Flutter build methods where argument types are usually known.
@bwilkerson @jwren @pq