file-lines do not reformat parts of a multi-line statement
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Imagine the following statement in which one line is wrongly indented:
let diff = repo
.diff_tree_to_workdir(Some(&head), Some(&mut diff_options))
.unwrap();
I now specify only the second line in my --file-lines.
What I expect to happen
The second line becomes correctly indented to match the same column as the .unwrap().
What actually happens
Nothing. The line is ignored because it is part of a larger statement.
Why this is a problem
I have a use case where a script uses git and --file-lines to only format lines which where changed in a specific commit. This script fails when someone just edits parts of a larger statement because the line is not formatted then. Adding more context to the range is also not viable because then lines are formatted that weren't touched in the commit.
#3397
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
Reproduce the example with rustfmt and the --file-lines option, using the multi-line statement shown in the issue. Trace how selected lines are handled when they belong to a larger statement; done means the selected line is reformatted without formatting untouched lines in the same statement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100