-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
Hitting enter on suggestion doesn't import module #73311
Comments
If you trigger suggestions and then wait until the details for that suggestion show up, I suspect it the import should be added as expected. @jordyvandomselaar Can you please test this @jrieken I debugged this issue and believe the root cause is that we are accepting a completion item that is not resolved. This was previously detailed in #63013 but we had to revert that fix as it caused other regressions. |
Thanks for the reply @mjbvz ! I've tested your suggestion and you're correct, after waiting it does import it. It does take quite long to load the details, is that something related? |
Thank you for checking. The details should never take this long to load. I've opened microsoft/TypeScript#31302 to look into why this is happening |
@mjbvz I see the issue you've opened has been resolved. Could you tell me when it'll hit the insiders edition version? That way I can check if the merged PR fixes this issue =) |
Maybe May, the problem is that commit/accept characters run strictly synchronous and that resolving details is async. Either we make TypeScript/JavaScript compute the extra edits eager or we find a better way of implementing commit characters... |
I have pushed a change that ensure completion items are resolve before inserting them, except for inserting/accepting via commit characters (due to its inherent sync nature). That should fix most issues tho @mjbvz Not sure what to do about the commit character case. Ideally, completion are "done" before resolve is called, e.g. resolve should only load detail/doc but nothing vital for insertion - the doc kinda suggests that. Not sure how feasible that is for TypeScript? |
Thanks. Unfortunately we cannot eagerly resolve TS completion items due to auto imports. It would be costly and very verbose for TS to generate the auto import information before the completion is resolved |
Turns out the changes aren't good... Resolving completion items while inserting them opens the door for out-of-order typing and worst. E.g. select I have reverted my changes and I have also removed the async-call when clicking an item - accepting a suggestion should be immediate, not delayed by anything. I will push a change so that the UI reflects if an item is still being resolved or not. I am also considering to call resolve more aggressively, e.g on render and not just on focus. This is an issue with TypeScript and everything needed to make the edits should come from the |
Hopefully with TS 3.5, users should rarely hit this issue. If we do want to show progress, a spinner would be more clear in my opinion. |
That's because they it isn't slow anymore, right? It's not that code actions become part of the suggestion without resolve? |
Yes, suggestions should be much faster for projects that use styled-components (or other complex type libraries). We have not changed how suggestions are resolved |
Adding @misolori for some UX inspiration - it's tricky because extensions shouldn't do this in the first place and showing progress for something that isn't vital is hard... |
No action planned from the suggest model side. I have added a doc comment to the resolve-function and ultimately extensions shouldn't do this but have completion items ready for insertion when providing them |
This comes up constantly in my experience and I hope a fix can be implemented! Here's the detail I filed at: #106361
Steps to Reproduce:
Result: Autocomplete happens but variable is not found because auto-import failed (Auto-import only succeeds if I wait an extra 0.5+ seconds until the Auto-Import suggestion loads.) Expected: If Auto-Import is turned on then Autocomplete of a variable not in the current file already should always auto-import; probably a Tab press should just bring up the Autocomplete suggestions or should not process until after that, because an autocompleted but not imported item that's going to be invalid seems likely to almost never be what the user wants. Notes: This took me a long time to diagnose because Auto-import usually just failed and I couldn't figure out why. It seems to me an unexpected and erroneous state if VS Code believes it can find an import, then autocompletes it, then afterward it's not found and invalid. This also slows down the user every time trying to Autocomplete because it will often be unknown if the import has been imported yet or not; if so then fast autocomplete is possible, if not then the user must wait for the Auto-Import box to show up or if autocomplete Tab press was submitted quickly, go back and autocomplete again, this time waiting for the auto-import box. Fixing this would probably save millions of times 1 second as autocompletes unexpectedly don't auto-import. Just finally understanding this issue is saving me a lot of frustration. Thanks for taking a look and for the great app. Does this issue occur when all extensions are disabled?: Yes |
Duplicate of #109439. Please give the 1.54 insiders builds a try when they come out later this week and let me know if you still see this issue |
Issue Type: Bug
For this example I'll be using React.
I have the following components;
When I try to use them inside another component I do get an auto completion with the correct name whilst typing
FlexBox
but when I hitenter
it doesn't import it (it does complete it), clicking on the suggestion with my mouse does work.Here's a video describing the problem;
https://monosnap.com/file/dqiy5IbunVfW9ExUZqFwusQy7EErdB
edit: It does show up as a quick fix to import it.
VS Code version: Code 1.33.1 (51b0b28, 2019-04-11T08:22:55.268Z)
OS version: Darwin x64 17.7.0
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Extensions (43)
(3 theme extensions excluded)
The text was updated successfully, but these errors were encountered: