Skip to content

Buggy autocompletion for traits like std::ops::Add #16080

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

Closed
joseph-amirth opened this issue Dec 10, 2023 · 3 comments · Fixed by #16101 or #16258
Closed

Buggy autocompletion for traits like std::ops::Add #16080

joseph-amirth opened this issue Dec 10, 2023 · 3 comments · Fixed by #16101 or #16258
Labels
A-completion autocompletion C-bug Category: bug

Comments

@joseph-amirth
Copy link

rust-analyzer version: rust-analyzer version: 0.3.1756-standalone

rustc version: rustc 1.74.0 (79e9716c9 2023-11-13)

relevant settings:
I am using archlinux and I've installed the rust toolchain using the usual rustup default stable command. I haven't modified the rust installation in any way.

Expected Behavior
When "impl Add" is typed, "Add" should appear in the autocompletion list as it is an exact match.

Observed Behavior
Add is in the autocompletion list when I am still typing prefixes of Add ("A" and "Ad") but when I type the entire word "Add", Add mysteriously disappears from the autocompletion list.

The behavior is as expected for other traits like AddAssign (I get "AddAssign" in the autocompletion list even when I've typed the entire name out), but for traits like Add, Neg, Sub, Mul I get this buggy behavior where once the name is fully typed out, it disappears from the autocompletion list. The only pattern I've noticed is that these traits have 3 letters but I can't imagine such an arbitrary condition could cause this.

Minimal Reproducible Example:

  1. Install VSCode and install the "rust-analyzer" plugin.

  2. Create a new project and above the main function, type "impl Add" and observe that "Add" appears in the autocompletion list when only prefixes of Add ("A"/"Ad") have been typed, but "Add" disappears from the autocompletion list once the entire word is typed.

@joseph-amirth joseph-amirth added the C-bug Category: bug label Dec 10, 2023
@Veykril
Copy link
Member

Veykril commented Dec 10, 2023

3 is somewhat magical here as we do prefix matching for 1 and 2 characters but fuzzy matching for 3 and more, so what might be happening here is that these traits are kicked out of the completions because of the current number of completions limit imposed when fuzzy searching.

@Veykril Veykril added the A-completion autocompletion label Dec 10, 2023
@joseph-amirth
Copy link
Author

If you try this with Mul, you actually get only 4 results once you've typed out "Mul" (the results of course do not include "Mul" itself), while you get 12 results once you've typed out "Add". So this doesn't seem like an issue with the completion limit.

@Veykril
Copy link
Member

Veykril commented Dec 12, 2023

#16107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion C-bug Category: bug
Projects
None yet
2 participants