Newline style changes to Unix-style when file is modified
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
On Windows, using the default newline style (either without rustfmt.toml or by explicitly setting newline_style="Auto":
- leaves the newlines intact if the file does not have any formatting issues (ok, expected)
- saves modified files with Unix-style endings, even when all line-breaks in the input file are CRLF.
I would expect that in such cases the "Auto" value would use the line-break style inferred from examining the file.
Version used: rustfmt 1.4.11-stable (9eb4b564 2020-01-29)
as invoked via the cargo fmt command, version cargo 1.42.0 (86334295e 2020-01-31)
It's possible to work around this by forcing "Native" style in the rustfmt.toml but the default behaviour results in a mixture of line-ending styles throughout the project and triggers git line-ending conversion warnings.
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 reproducing the issue on Windows through the mentioned cargo fmt entry point, using a CRLF file with a formatting change and the default Auto setting. Trace how Auto chooses newline style and add coverage for preserving the input style; done means modified CRLF files remain CRLF without requiring Native, with the relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100