Skip to content

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

Closed
@Crzyrndm

Description

@Crzyrndm

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions