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

Autocomplete/Hints randomly not working #12566

Closed
brxken128 opened this issue Jun 17, 2022 · 10 comments · Fixed by #12899
Closed

Autocomplete/Hints randomly not working #12566

brxken128 opened this issue Jun 17, 2022 · 10 comments · Fixed by #12899
Labels
A-completion autocompletion C-bug Category: bug

Comments

@brxken128
Copy link

brxken128 commented Jun 17, 2022

I've had this issue for a while now, and I'll try to be as descriptive as I can.

Within a function, autocomplete sometimes completely stops working (it says "no suggestions"). I'm using only rust-analyzer for Rust, and VSCode. This issue has persisted across multiple installs of both VSCode, and Void Linux. I also had the issue on Fedora 36.

The issue seems to happen randomly, but the easiest way I can reproduce it is by bringing more than one error into scope.

Here's some example code:

pub fn x() -> Result<()> {
    let x = Instant::now();
    let _ = test(v1, v2, v3)?;
    let x_duration = x.elapsed();
    logger.success(format!(
        "Success",
        x_duration.as_secs_f32()
    ));
}

Under normal circumstances, selecting the end of Instant and hitting ctrl+space would bring the menu up, offering to import std::time::Instant - but it doesn't.

It also sometimes happens just randomly, either showing "no suggestions", or relaying a list of my variable names to me.

Using rust-analyzer 7322a982f 2022-06-16 (I'm not too sure where to find a version string)

@Veykril
Copy link
Member

Veykril commented Jun 17, 2022

What r-a version are you using?

@brxken128
Copy link
Author

brxken128 commented Jun 17, 2022

What r-a version are you using?

I knew I had forgotten something, it's 7322a982f 2022-06-16

@Veykril
Copy link
Member

Veykril commented Jun 17, 2022

completions randomly failing should be fixed since last week. The issue of flyimport not working in Instant$0::now where $0 is the cursor seems to be new, probably due to one of my recent refactors.

@Veykril Veykril added A-completion autocompletion C-bug Category: bug labels Jun 17, 2022
@brxken128
Copy link
Author

brxken128 commented Jun 17, 2022

I don't think so - I have had the issue for a while (maybe a month or so). I'm currently writing code and it seems to be getting worse, but I'm not too sure how.

Are there any logs that could be useful?

@Veykril
Copy link
Member

Veykril commented Jun 17, 2022

No, logs won't be useful here. Only example snippets where this occurs like the one you gave here.

@brxken128
Copy link
Author

brxken128 commented Jun 17, 2022

Forgive the fact that it's a screenshot, there is an awful lot of code involved.

This is within main(), and match statements (used for clap's builder API)

Screenshot

Edit: This probably won't be able to be replicated, but I hope the full code can at least help narrow the issue down:

fn main() -> Result<()> {
    let matches = cli::get_matches();

    match matches.subcommand() {
        Some(("header", sub_matches)) => match sub_matches.subcommand_name() {
            Some("update-key") => {
                let sub_matches_update_key = sub_matches.subcommand_matches("update-key").unwrap();
                let keyfile_old = if sub_matches.is_present("keyfile-old") {
                    KeyFile::Some(
                        sub_matches
                            .value_of("keyfile-old")
                            .context("No keyfile/invalid text provided")?
                            .to_string(),
                    )
                } else {
                    KeyFile::None
                };

                let keyfile_new = if sub_matches.is_present("keyfile-new") {
                    KeyFile::Some(
                        sub_matches
                            .value_of("keyfile-new")
                            .context("No keyfile/invalid text provided")?
                            .to_string(),
                    )
                } else {
                    KeyFile::None
                };
                subcommands::header::update_key(&get_param("input", sub_matches_update_key)?, keyfile_old, keyfile_new)?;
            }
        }
    }
    Ok(())
}

(p.s. apologies for the messy code - a refactor is planned)

@Veykril
Copy link
Member

Veykril commented Jul 28, 2022

Are you still having this problem?

@brxken128
Copy link
Author

Are you still having this problem?

Yes sadly - I opened VSCode yesterday and saw similar issues.

@Veykril
Copy link
Member

Veykril commented Jul 28, 2022

Ah, wait this is actually reproducible for me, that is trying to ask for completions in a path qualifier (not sure what I did wrong earlier in my testing).

@brxken128
Copy link
Author

Thank you!

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
Development

Successfully merging a pull request may close this issue.

2 participants