rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Autocomplete / code hints not working on variable names

Open frozenranger opened this issue 2 years ago • 12 comments

I lose auto-complete on some variable names when trying to access the variable from multiple threads and loops. Unfortunately, I couldn't replicate it in a bare minimum example however I made a short video with the bug. The code still runs fine.

https://youtu.be/OPDkgGOr78o

Thank you very much for your time!

frozenranger avatar Jun 17 '22 03:06 frozenranger

It's very tedious to look at a video and try to reproduce this issue. If you can minimize the repro and post the code, it would help the maintainers fix this issue.

jhgg avatar Jun 17 '22 04:06 jhgg

fn main() {

let mut xx = 0;

if xx { //autocomplete does not show up for variable name "xx"
//first type if, then type x, wait for autocomplete to popup... it will not show "xx"
// now try with original rust-lang support on, it will popup correctly after typing just "x"


}

}

Thank you

frozenranger avatar Jun 17 '22 21:06 frozenranger

Looks like this happens in general after typing if (note the space), similar for while . This seems to be an issue with snippets?

Veykril avatar Jun 17 '22 21:06 Veykril

@Veykril Hi! Thanks for making it actionable! Also if you get a chance the video is only 1 min 33 seconds and illustrates the problem very well :)

I am still a noob in rust and programming in general, I'm not sure what a snippet is?

Thank you for the consideration, have a good day

frozenranger avatar Jun 17 '22 22:06 frozenranger

If you type out if you'll see completions like the following image The if let completion there is a snippet (it can set your cursor to a position and pre-select text after invoking the completion). To me it looks like this plays weird with completions afterwards, since typing xx will make the completions show again for me afterwards. I am currently in the middle of refactoring large parts of the completions code base after which I can look into this.

Veykril avatar Jun 17 '22 22:06 Veykril

If you get a minute, check the video I uploaded, it also occurs without the if statement or keywords in some cases. I haven't determined what is causing that but maybe once you see the video it will make sense to you guys?

frozenranger avatar Jun 17 '22 23:06 frozenranger

@Veykril This doesn't happen in Emacs, btw. (The if let and while let snippets don't work correctly though -- they replace if <|> by if if let ...)

flodiebold avatar Jun 18 '22 08:06 flodiebold

@frozenranger I don't think your small example is the same problem as in your original video. Maybe try gradually removing code from the example in the video and seeing how that changes the results?

flodiebold avatar Jun 18 '22 08:06 flodiebold

@flodiebold ok I will try that. Hopefully I can isolate the issue better. Thanks for watching the video :) I noticed a few views so that's great!

frozenranger avatar Jun 18 '22 23:06 frozenranger

Looking into this, this seems to be a bug in VSCode. When (space) is entered it does not re-request the completion list and keeps the old one, then on the next character input press it still does not re-request completions

Veykril avatar Jul 28 '22 14:07 Veykril

Is this also related to not seeing certain variable names depending on how far away that variable name is? Sometimes when there are large amounts of code, autocomplete does not find the previous variables used? Thank you

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Lukas Wirth @.> Sent: Thursday, July 28, 2022 10:18:10 AM To: rust-lang/rust-analyzer @.> Cc: frozenranger @.>; Mention @.> Subject: Re: [rust-lang/rust-analyzer] Autocomplete / code hints not working on variable names (Issue #12557)

Looking into this, this seems to be a bug in VSCode. When (space) is entered it does not re-request the completion list and keeps the old one, then on the next character input press it still does not re-request completions

— Reply to this email directly, view it on GitHubhttps://github.com/rust-lang/rust-analyzer/issues/12557#issuecomment-1198204701, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AL54ENXWHEKW74IS3MNXOCLVWKJCFANCNFSM5ZA4CMZA. You are receiving this because you were mentioned.Message ID: @.***>

frozenranger avatar Jul 28 '22 23:07 frozenranger

No, that's something else.

Veykril avatar Jul 29 '22 06:07 Veykril

Awesome! Thanks everyone :) looking forward to seeing the next push!

On Fri, Jun 17, 2022, 6:09 PM Lukas Wirth @.***> wrote:

If you type out if you'll see completions like the following [image: image] https://user-images.githubusercontent.com/3757771/174407065-66d890d0-9084-4f81-998b-f179c4cf47ef.png The if let completion there is a snippet (it can set your cursor to a position and pre-select text after invoking the completion). To me it looks like this plays weird with completions afterwards, since typing xx will make the completions show again for me afterwards. I am currently in the middle of refactoring large parts of the completions code base after which I can look into this.

— Reply to this email directly, view it on GitHub https://github.com/rust-lang/rust-analyzer/issues/12557#issuecomment-1159265560, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL54ENR7LDMVO2XXEK5NSRTVPTZR5ANCNFSM5ZA4CMZA . You are receiving this because you authored the thread.Message ID: @.***>

frozenranger avatar Oct 11 '22 08:10 frozenranger