-
Notifications
You must be signed in to change notification settings - Fork 55
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
Ranking unresolved imports with better relevance #340
Comments
Interesting ideas. I think it definitely makes sense to peek into the When it comes to ranking and reordering, I worry that no ranking solution will be "good enough". Having to resolve an ambiguous import is already disrupting as it is, and having the selection list ordered in a different way might not help much. Using a simple strategy that people understand and that always results in the same order might actually be easier to use. Maybe @wincent can chime in here too? He's the author of Command-T and I've seen him deal with things like this a few times. |
Looking at other more sophisticated IDE such as IntelliJ, it is definitely a good user experience if the first choice is almost always the desirable result. |
That's a good point, and it makes sense. If we can make it "right" in 9/10 cases it makes sense to have a more sophisticated sorting strategy. For your second point, the |
I don't have a horse in this race, but I do think a simple, opt-in heuristic might be worth looking at. One example of that would be having the ability to filter out non-top-level node modules. Ranking is much harder than blanket filtering though. |
Thanks @wincent for chiming in. At the moment we're not peeking in to any node modules folders, but we're discussing doing so for the top-level ones (those listed in package.json). Right now you can import a package dependency, but only by its name. You can make import-js 🏁 🏇 🏇 🏇 🏇 |
Yeah, I think we need to look at the files in each of the top-level dependencies. I'm a little worried about relevance, of the results, but maybe it will be okay. One idea I have is to only consider files in the |
I think we need to include files in packages when matching, so I've opened #344 to track that. We can discuss and improve ranking of matches separately here. |
2.5.0 included a change that sorts the unresolved imports by path distance to the current file. I think there's more that we could do here, but this seems like a good and simple step in the right direction. |
There is a requirement that we want to find enough modules to import from. But it also brings up noise and brings down performance.
An idea to optimize performance: scan through the all the node_modules, but skip all its sub node_modules. It's rare to import anything from node_modules of a node_modules module, while those files are the most costy and noisy.
Ideas to rank the possible imports:
I don't have specific algorithm in mind yet but it can be some heuristic approach.
@lencioni
The text was updated successfully, but these errors were encountered: