basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

nonsense autocomplete suggestions

Open cangkuai opened this issue 2 years ago • 15 comments

import numpy as np

# After typing 'as', the code editor suggests auto-completions, which is unexpected.

cangkuai avatar Apr 17 '24 04:04 cangkuai

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

DetachHead avatar Apr 17 '24 05:04 DetachHead

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

cangkuai avatar Apr 17 '24 05:04 cangkuai

Because this problem greatly affects the user experience

cangkuai avatar Apr 17 '24 05:04 cangkuai

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

KotlinIsland avatar Apr 17 '24 05:04 KotlinIsland

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.

KotlinIsland avatar Apr 17 '24 05:04 KotlinIsland

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.

DetachHead avatar Apr 17 '24 06:04 DetachHead

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 avatar Apr 17 '24 06:04 cangkuai

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

cangkuai avatar Apr 17 '24 06:04 cangkuai

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

KotlinIsland avatar Apr 17 '24 06:04 KotlinIsland

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 avatar Apr 17 '24 08:04 cangkuai

Even the Enter key will trigger code auto-completion

cangkuai avatar Apr 17 '24 08:04 cangkuai

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

KotlinIsland avatar Apr 17 '24 22:04 KotlinIsland

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 avatar Jun 07 '24 01:06 KotlinIsland

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

KotlinIsland avatar Jun 07 '24 01:06 KotlinIsland

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

DetachHead avatar Sep 10 '24 11:09 DetachHead