-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: auto-complete import for aliased function and module #18382
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
Conversation
crates/ide-completion/src/render.rs
Outdated
// Use the last segment when `item_to_import` matches `original_item`, | ||
// as it will take the aliased name into account. | ||
let local_name = if import_edit.item_to_import == import_edit.original_item { | ||
import_edit.import_path.segments().last()?.clone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is a right way to get the aliased name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a decent workaround for the core issue I mentioned for now I think, could put a FIXME comment mentioning #14079 as the proper fix for this above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the FIXME.
There was a similar case with completion in pattern as well, so I added a testcase with the same fix.
So, the root issue is due to #14079, basically we should be treating imports as their own items to refer to. I'd need to look into that issue again to tell where we are with it (iirc only the IDE integration is missing, but that is still quite a bit to work on) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Close #17042
Get the aliased name from
import_path
to use for import instead of name defined inside local module.