-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Incorrect auto import added for suggestions where same symbol name is exported from multiple files #42752
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
@mjbvz ok, so, there is a TypeScript bug here, but it’s not the fact that the path shown is not the module specifier you end up with. The path text you’re looking at was never meant to be shown to humans. As I mentioned in #42005, that path is purely an identifier that TypeScript uses to correlate completion entries between the CompletionsRequest and the CompletionDetailsRequest, so we can come up with a good module specifier in the latter. It’s specifically commented in the protocol as “not necessarily human-readable,” but VS Code decided to start displaying it in this PR. Once you focus a completion, we calculate the actual module specifier that we think you want, and that’s what you’re guaranteed to get. The left side of this screenshot shows the calculated module specifier; the right side is simply the path to the file where it was declared: Occasionally, the path will be the same as the module specifier, but I would say this is actually rare for most projects. Even if we could show the user something better immediately for every item in the list, we would need to send you that in a separate property of the response, because we have to have this simple path to be able to fulfill the completions details request correctly, resolving ambiguities between different entries of the same name. I would really love to be able to calculate final module specifiers for every auto-import completion, but we currently don’t because it would increase the amount of time it takes for completions to show up at all. So, there are two issues:
|
Thanks for the investigation @andrewbranch We think there's a lot of value in showing auto-import information inline for suggestions and went ahead with this hacking approach knowing that we'd hit some limitations. We had #36265 but it look like that has stalled |
Bug Report
From microsoft/vscode#116375
🔎 Search Terms
🕗 Version & Regression Information
Seen on 4.2.0-20210210 and 4.1.5
💻 Repo
Disposable
export class ExtensionsLifecycle extends Disposable
, trigger suggestions at the end ofDisposable
Disposable
fromweb.api
:🙁 Actual behavior
I expected this to add an import from
web.api
🙂 Expected behavior
It actually ends up adding the import from
import { Disposable } from 'vs/base/common/lifecycle';
I believe this is because the
Disposable
fromweb.api
is a re-export of the one fromlifecycle
You can also get into the reverse state, where the suggestion for
lifecycle
ends up adding an import fromweb.api
. Here are thecompletionEntryDetails
from that case:The text was updated successfully, but these errors were encountered: