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

nonsense autocomplete suggestions #304

Open
cangkuai opened this issue Apr 17, 2024 · 15 comments
Open

nonsense autocomplete suggestions #304

cangkuai opened this issue Apr 17, 2024 · 15 comments
Labels
language server LSP: completions LSP: import suggestions import suggestions can show as either a code action or autocomplete suggestion

Comments

@cangkuai
Copy link

cangkuai commented Apr 17, 2024

import numpy as np

# After typing 'as', the code editor suggests auto-completions, which is unexpected.
@DetachHead
Copy link
Owner

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 DetachHead changed the title Bug Report: Auto-completion after 'as' in Python nonsense autocomplete suggestions Apr 17, 2024
@cangkuai
Copy link
Author

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

@cangkuai
Copy link
Author

Because this problem greatly affects the user experience

@KotlinIsland
Copy link
Collaborator

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

@KotlinIsland
Copy link
Collaborator

KotlinIsland commented Apr 17, 2024

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
Copy link
Owner

DetachHead commented Apr 17, 2024

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 DetachHead added the vscode the extension for vscode/vscodium label Apr 17, 2024
@cangkuai
Copy link
Author

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
Copy link
Author

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
Copy link
Collaborator

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

@cangkuai
Copy link
Author

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
Copy link
Author

Even the Enter key will trigger code auto-completion

@KotlinIsland
Copy link
Collaborator

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

@DetachHead DetachHead added the LSP: import suggestions import suggestions can show as either a code action or autocomplete suggestion label Apr 17, 2024
@KotlinIsland
Copy link
Collaborator

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
Copy link
Collaborator

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 DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2024
@DetachHead
Copy link
Owner

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 DetachHead reopened this Sep 10, 2024
@DetachHead DetachHead added LSP: completions and removed vscode the extension for vscode/vscodium labels Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language server LSP: completions LSP: import suggestions import suggestions can show as either a code action or autocomplete suggestion
Projects
None yet
Development

No branches or pull requests

3 participants