Skip to content

VSCode (?) : Prefer suggestions that are in already in scope #12068

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
Crzyrndm opened this issue Apr 23, 2022 · 0 comments · Fixed by #12074
Closed

VSCode (?) : Prefer suggestions that are in already in scope #12068

Crzyrndm opened this issue Apr 23, 2022 · 0 comments · Fixed by #12074
Assignees
Labels
A-completion autocompletion

Comments

@Crzyrndm
Copy link

Crzyrndm commented Apr 23, 2022

Rust analyser version: 0.2.1022 (current stable)
VSCode version: 1.66.2 (current stable)

Probably the most irritating paper cut I have when using RA is the first (few) suggestions requiring a new import when something that would match perfectly (and generally what I want) is already in scope.

Here the 4th suggestion I would think is most appropriate (no imports required). Whether the crate::... match should be next is debatable (my first reaction would be yes but there's probably a good example to counter it)
image
Particularly when jumping in from another language I tend to assume the top suggestion will be the one in scope and often end up with extra imports I didn't want while typing quickly

<...>.as_slice() importing slice::SlicePattern (and requires an unstable language feature) is a particularly common offender for causing this. I can't recall a simple example where it comes up first but it has definitely happened (the number of times I've had to remove that particular import...)
image
image
Not 100% sure what the best resolution is here, but there are several issues in this particular case

  • Duplication of an existing suggestion requiring no import
    • Useful for feature discovery maybe, but creates clutter that obstructs progress
    • Perhaps an option to remove duplicates that require imports when there is an exact match already in scope? Alternatively, send them to the bottom of the suggested list (i.e. you may also be looking for...)
  • Suggestion of an unstable feature for a project using a stable compiler
    • even on nightly I would probably prefer it wasn't presented unless I had already enabled the feature gate but presenting it on a stable project just feels outright incorrect behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants