rust-lang / rust-lang/rust-analyzer
Add an option to disable auto-formatting of the action "Fill struct fields"
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Hi.
Since a couple of weeks, the action "Fill struct fields" will automatically format the code.
This often results in putting all the fields on the same line which I find harder to edit compared to the previous behavior of having one of them per line.
And usually, after adding the values, it will be formatted on multiple lines anyway, so I don't see much benefit to auto-format the result of this action immediately.
For this code:
args: vec![TypedExpr {
}],
rust-analyzer would previous give the following code after the action:
args: vec![TypedExpr {
expr: todo!(),
pos,
typ: todo!(),
}],
now it gives:
args: vec![TypedExpr { expr: todo!(), pos, typ: todo!() }],
Could you please add a setting to disable the auto-formatting (so that we get the previous behavior) for actions like this?
Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of the "Fill struct fields" action and where it invokes formatting. Trace how action settings are represented, then determine how an option could preserve the previous multiline output. Done means the action can skip auto-formatting when the option is disabled, while retaining current behavior by default and covering both modes with tests.
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
- 45/100