-
Notifications
You must be signed in to change notification settings - Fork 771
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
Word and snippet completions being shown when Pylance does not have any completions #604
Comments
So, this is due to the fact that we're no longer offering completions in contexts we can't actually know the name for (#163). But it seems that since we now return empty, VS Code's word suggestion is taking over and suggesting things. If you set this, I believe it should work around the issue: "[python]": {
"editor.wordBasedSuggestions": false
} The real fix may be to always give back something in the completion list, e.g. here offer up the thing the user already typed. I think TS does this. |
@heejaechang FYI |
Thanks, the workaround makes sense! I can imagine offering the user-typed input as the first choice may have some edge cases that are not desirable. I wonder if it's possible to treat aliasing, specifically, differently from other situations where the user may not want the completion's first choice as what they just typed. |
We already know the context you're typing in (to know to explicitly return nothing), so adding this special case is likely to be okay. Just needs some investigation and testing. |
@prrao87 thank you for reporting. so, I tried to see old experiences, typescript experiences and etc. as you can see, we used to add what the user has written so far into the list. I don't believe it was by design, but it happens to add those since it basically showed any symbols defined in the current scope which includes what the user has written so far. due to that, it won't work if there is a syntax error such as I tried typescript to see how they behave it looks like typescript also behaves the same as us. that being said, we can improve behavior around this if we want to (@savannahostrowski @judej) options I can think on top of my head will be
|
Option 1 (turning off wordBasedSuggestions) is doing the trick quite well for me right now - but it's not at all obvious to new users to know that this is the option they need to turn off to get the right behaviour. In the end, it would be nice to have an easy, intuitive system for beginners within Pylance that doesn't require users to disable VS Code editor settings! |
@prrao87 I agree. so (1), what I meant was we change default for wordBasedSuggestions for python to off. so there is nothing user need to do. it will be automatically off for python file. but users who really want wordBasedSuggestion can explicitly turn it on. and only those people need to know the option. not the other way around. |
Also relevant is #629, as VSC will also try and offer up snippets. Since we don't send anything, they're highly ranked. (4) would fix that too, but we'd have to test and see how we feel about it. Maybe we only do (4) in the contexts where it's a "new name". |
my opinion is just doing simplest thing first (1) and see whether we get any feedback from users. |
Pylance 2020.12.0 now includes (1). I don't want to close this quite yet to see how this works out, or if we need to try another method. Please let us know! |
Updating the title of this to better reflect; we did the word completion thing, but snippets remain a problem. We may need to attempt the method where we add a fake completion for the prefix. |
@jakebailey I'm really conflicted about snippets - on the one hand it's annoying to keep on because it does things like suggest On the other hand, I really like the convenience of the Do you know whether there's a workaround to get the second behaviour but not the first? Is it possible to disable snippets but still be able to generate boilerplate like in the second case using just Pylance? I know you're doing your best to track all these issues in various places, so thanks a lot for your efforts! |
It's a VS Code quirk. We answer the completion request with "there are no completions", but then it also offers up word and snippets. This means that those are the only choices, and then they get picked and do the wrong thing. There isn't a way to selectively choose snippets that as far as I remember, maybe there's a way to disable specific snippets but I haven't tried. |
The most recent version of the core extension dropped snippets altogether. With our word completion default set to false, I'm not entirely certain this is a problem anymore, but the idea to always offer "what was typed" as a completion may be a useful idea if we want to ensure we don't break if word completion is enabled. |
I agree, the "what was typed" is definitely something I see as being useful in the long term. |
Thanks for the report. This has been fixed. Please reopen if this is still an issue. |
Environment data
Expected behaviour
When typing in import statements with aliases (e.g.,
import pandas as pd
orimport numpy as np
), the autocomplete suggestion should provide the currently entered alias (pd
ornp
) as the top choice. Then, simply pressing Enter would allow the user to continue typing in the next line.Actual behaviour
The currently typed alias (
pd
ornp
) is not shown at all, so pressing Enter at the end of the import statement selects the library name (pandas
ornumpy
), which is really annoying. The only way to retain this is to press space and then enter, which results in redundant spaces at the end of each import statement.Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: