Skip to content
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 Import only on key press #178

Closed
spinelsun opened this issue Jul 27, 2020 · 4 comments
Closed

Auto Import only on key press #178

spinelsun opened this issue Jul 27, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@spinelsun
Copy link

Hi,

I would like to have the ability to choose when the auto-import actually imports modules, functions, etc.
Currently, when I press Tab or Enter on IntelliSense completion suggestion the auto-import always imports the suggestion even if it is not necessary.
For example, when writing tests and using fixtures there is no need to import fixture from conftest.py or any other global module.
Another example, if I define a const variable name EXAMPLE in one module when I try to create EXAMPLE in another module auto-import will import the first one

I think that adding a keystroke to auto-import will be the best solution. Maybe when IntelliSense suggests something enter will take this suggestion without auto-import and tab will auto-import.

Thanks

@jakebailey
Copy link
Member

Note that this would need to be a VS Code change and LSP change; neither offer this sort of thing. Completions are a request purely dependent on the file state and the location. A server is typically expected to return the same thing each time, and the client is free to cache requests and not ask the server again.

@yzhang-gh
Copy link

I second this (it will be better if we make the auto-import operation more perceivable).

The story is: I found there were unexpected auto-imports several times (they were not noticeable until I ran the code) so I disabled this feature. Today I re-enabled it as it is indeed a nice feature. But soon I again got an unexpected auto-import. (I wanted to claim a variable named cluster but sklearn.cluster was auto-imported without awareness... 😑) It's so frustrating.

I think the problem is the mismatch between user expectation and the auto-import behaviors in practice. In short, users cannot notice unexpected auto-imports in time. (A naive solution I could think of is to show a status message (last for 2 seconds) whenever we have an auto-import.)

@jakebailey
Copy link
Member

I'll note that the original issue would benefit from #163; we shouldn't be offering those sorts of name completions at all.

@judej
Copy link
Contributor

judej commented Apr 21, 2022

Closing since the original issue is resolved. @yzhang-gh, if you would like to, you could add an enhancement discussion in the "discussions" section

@judej judej closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants