-
Notifications
You must be signed in to change notification settings - Fork 1k
file-lines can modify lines above the selected range #6863
Copy link
Copy link
Closed
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueStatus: a Minimal Complete and Verifiable Example has been found for this issueUO-file_linesUnstable option: file_linesUnstable option: file_lines
Metadata
Metadata
Assignees
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueStatus: a Minimal Complete and Verifiable Example has been found for this issueUO-file_linesUnstable option: file_linesUnstable option: file_lines
Type
Fields
Give feedbackNo fields configured for issues without a type.
When using
--file-linesto only partially format a function body, an unselected line immediately preceding the selected range can also be touched.Summary
Consider the following example file
test.rswhere lines 2-4 in the function body are indented incorrectly:If I format with
--file-lines '[{"file":"test.rs","range":[2,2]}]'then I get the correct output, with only the code on line 2 changed:But if I attempt to format only line 4 with
--file-lines '[{"file":"test.rs","range":[4,4]}]'then line 3 gets incorrectly formatted along with line 4:Configuration
rustfmtcli options used:rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[4,4]}]' test.rs