rust-lang / rust-lang/rust-analyzer

Struct field complete suggestion should follow declaration order instead of alphabetical

Open
#20,870 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Image

This is one of the subtle things that I've always hated: I expected the suggestions to follow the declaration order, but it has been alphabetical instead. It causes all kinds of headaches when later I'm changing the fields and can't find the field easily in the new method, because I filled the fields with the suggestion order instead of declaration order and now it's all messed up.

Notice how the declaration goes "source, start, index, line" and the suggestion goes "index, line, source, start".

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 struct field completion shown in the issue and trace the rust-analyzer completion entry point responsible for ordering suggestions. Determine how declaration order can be observed there, then verify that fields appear as source, start, index, line rather than alphabetically, with coverage for the reported example.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.