DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.15k stars 20 forks source link

nonsense autocomplete suggestions #304

Open cangkuai opened 6 months ago

cangkuai commented 6 months ago
import numpy as np

# After typing 'as', the code editor suggests auto-completions, which is unexpected.
DetachHead commented 6 months ago

i can reproduce it, but only sometimes. seems to be an upstream pyright issue:

image

its not just import ... as statements tho, these nonsense suggestions show up all over the place, for example:

image

all 3 of these suggestions would insert a syntax error

cangkuai commented 6 months ago

I think disabling code completion for "as" is a good temporary solution

cangkuai commented 6 months ago

Because this problem greatly affects the user experience

KotlinIsland commented 6 months ago

This is just normal functionality of vscode, when you trigger auto complete at any position, it will suggest random words image

KotlinIsland commented 6 months ago

The identical behavior can be observed in javascript: image

Can I ask, why you find the auto completions here to be unexpected and detrimental to the user experience?

I personally don't use import aliases, but it would seem reasonable to me that the IDE would provide suggestions for alias names.

DetachHead commented 6 months ago

Can I ask, why you find the auto completions here to be unexpected and detrimental to the user experience?

i find them extremely annoying, especially in cases where they would insert obvious syntax errors.

even if it also happens for other languages, if these stupid nonsense suggestions are coming from the language server or the vscode extension (rather than vscode itself), then i can and will get rid of them.

cangkuai commented 6 months ago

The identical behavior can be observed in javascript: image

Can I ask, why you find the auto completions here to be unexpected and detrimental to the user experience?

I personally don't use import aliases, but it would seem reasonable to me that the IDE would provide suggestions for alias names.

Because python has many commonly used nicknames, such as numpy is called np, pandas is called pd, and matplotlib.pyplot is called plt.

cangkuai commented 6 months ago

Now if I want to use these nicknames, I need to complete the code automatically, delete the automatically completed characters, and then enter these nicknames

KotlinIsland commented 6 months ago

Can just type the nickname without activating the auto-complete?

cangkuai commented 6 months ago

After 10 minutes of trying, I found that only the space key can not trigger automatic code completion, but it will leave an extra space after the "import" line.

cangkuai commented 6 months ago

Even the Enter key will trigger code auto-completion

KotlinIsland commented 6 months ago

I found that if I press the right arrow/escape it will dismiss the suggestion box.

KotlinIsland commented 5 months ago

Now if I want to use these nicknames, I need to complete the code automatically, delete the automatically completed characters, and then enter these nicknames

VSCode has a command 'hideSuggestWidget' that, by default is bound to esc. read more here: https://stackoverflow.com/a/53136645

KotlinIsland commented 5 months ago

Solution

Disable this setting and random words will not be injected into your suggestions image

Additionally, all suggestions can be set to "inline" mode so that they are less intrusive: image

DetachHead commented 1 month ago

re-opening this as there are actually plenty of invalid completions in pyright, these still appear when editor.suggest.showWords is disabled:

image

image

related: #663