rust-lang / rust-lang/rust-analyzer

Add an option to disable auto-formatting of the action "Fill struct fields"

Open
#17,130 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.