-
Notifications
You must be signed in to change notification settings - Fork 767
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
Auto-imports only work for code from currently open files when indexing is enabled #1055
Comments
Thanks for this; it's hard to find people who are actually using our insiders features... Before we disabled it (sorry!), did you experience any sort of performance troubles with indexing? Or was it not a problem and the feature was worth the extra CPU time spent working? Did completions show up in a reasonable amount of time? I'm very curious about your codebase and how it helped/hurt. |
So we're looking into moving our Python dev team over to VS Code with Pylance (one of the main reasons being that dev containers are really appealing to us, for what it's worth). This team relies heavily on auto-imports, symbol search and reference search, and enabling indexing seems to be the only way to make those (mostly) work for our large codebase. We do see performance problems with indexing, as already discussed in #997 also. More specifically, completions and auto-imports can definitely be slow at times. The performance issues are enough of a turn-off to keep the team from switching over permanently at this point in fact, but not having the full functionality makes things even worse for us I'm afraid. I guess I was hoping that VS Code with Pylance could still be an option for us further down the road, as indexing performance improves over time. This change is more of a step backwards that makes that all less feasible however. We'd be happy to test things out and/or provide info/feedback if that can help to keep the dream alive though :) |
@klbostee how about providing the ability through code action? (the light bulb), we are trying to reduce things that affect typing such as completion but fine some feature taking more time on user explicit command such as code action. for example, we already suggest "add import" for mis-spelled symbol in code action but not in completion or we include lower case variables in __ all __ in code action but not in completion. |
Providing it (only) through a code action sounds like a good potential solution to me @heejaechang. I'd have to ask the others in the team, but for me it was typically already very similar to this in practice anyway. The red curly line would appear because the symbol isn't defined, and then I'd trigger an auto-complete by hitting ctrl+space and pick the auto-import. So the only difference would be having to trigger code actions instead of auto-complete. Some of our devs are pretty religious about being able to access everything via the keyboard, but I just checked and there seems to be a keyboard shortcut for code actions too (cmd+.) so that shouldn't be an issue. |
The next release (later today) will re-eanble it for code actions (quick fixes), but not for completions. We'll see how far that get us, and use this thread for further feedback. |
Did |
We should fully index all files within the project though. I'm guessing that |
I am sorry, I was under the impression that this has been working. But I may have just made this up... I am actually unsure now. Is there any way to make this work with the current release of pylance? |
Right now, we have some hardcoded limits in the indexer as we work on ways to improve its performance. Most packages are limited to the top level, but django is restricted to two levels, but We've recently identified some more perf improvements, so we'll see what we can do, but at the moment there isn't a way for you to tweak this externally. |
Today's release (2021.5.3) includes stricter filtering on auto-imports which should mitigate some of the performance problems we have with offering far too many symbols. If this goes well, it's likely we can look into re-enabling auto-imports that make use of the user code index, but we'll see (I don't want to jinx it). |
Do you have any details on how the logic changed and are there any settings to tune the behavior? |
The change is that auto-import completions at least need to start with the same character as what has already been typed. This is something that is currently being put into TypeScript's auto-import system, as they have similar issues to us with offering so many completions that performance is greatly affected. Quick fixes remain unchanged. There are no settings to tune this behavior. Is there a reason you're looking for a way to change it? Happy to take feedback as to how this may break; the intent is to filter out the bulk of the completions nobody is accepting. |
Just curiosity in case I noticed something strange so I can try things out before posting something here. |
I also noticed that for a multi-root workspace I often don't get proper suggestions from the code in another root. This is quite annoying when you have a core project and a plugin repo, and usually import stuff from the core in plugin code. The repos are linked above so if you want to investigate this further feel free to try with them (I have one root for the core project and one for the folder containing all the plugins). Especially the In terms of sorting, it's also a mix between thirdparty (site-packages) and custom code. Having imports from own code come first would be nice... |
Multi-root is its own problem, because the roots do not interact with each other (and in fact get their own distinct analysis). Having a multi-root workspace does not imply that one workspace can import from another as though the other roots are on IIRC you need to set extraPaths to get them to recognize each other. |
I tried setting Anyway, in the language server output I see this, so the src dir is clearly in the path - I do not get completions for imports coming from there though.
If I use CTRL+T I do find those symbols though, so they are clearly being indexed. |
we have added an option to include more symbols from third party libs if user wants, see this #2312 (comment) I also opened this issue to track UX on multi root workspace - #2601 |
Just chiming in that I feel like auto-import and finding references has gotten worse quite recently, maybe in the past 1-2 weeks. When I "Find all references", it seems like Pylance is missing references more and more. This is all for code within my workspace, not external libraries. VSCode: Sorry this isn't a more useful report :/ |
Same here. I updated vscode, and suddenly auto-import does not recognize the local package anymore. |
@jli, @adamalpi, can you see if setting |
@debonte updated ubuntu and all the software |
@solarw, please file a new issue. |
Environment data
Expected behaviour
I would expect pylance to be able to auto-import any symbol from my codebase, not only from currently open files.
Actual behaviour
As mentioned in the changelog for 2021.3.1, auto-imports now only work for code from currently open files when indexing is enabled. The release notes also said "please file an issue if you have enabled indexing and this affects your workflow", which is what I'm doing right now :)
Additional information
This does indeed affect our workflow quite a bit. Could it at least be made configurable maybe?
The text was updated successfully, but these errors were encountered: