rust-lang / rust-lang/rust-analyzer

Autocomplete order seems to prefer recursion

Open
#13,925 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-completion C-enhancement
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I feel like r-a could be a little smarter about the ordering of autocomplete suggestions inside / at the start of a method implementation:

Screenshot of a method "fn sender_avatar_url(&self) -> Option<&MxcUri>" with the incomplete body "self.sen" and an autocomplete popup which shows six items, the first of which is a call to the method itself, then another field plus its accessor and only then the field of the same name as the method plus two more items

Recursive functions are pretty rare in general, and recursing unconditionally right at the start of the function is practically never the right thing to do.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the autocomplete case shown in the issue, inside a Rust method implementation where the partially typed expression is self.sen. Start by investigating rust-analyzer's completion-ranking behavior and compare recursive calls with fields and accessors. Done means the suggestions no longer place an unconditional recursive call ahead of more likely members in this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.