rustfmt icon indicating copy to clipboard operation
rustfmt copied to clipboard

Backport 4236

Open ytmimi opened this issue 3 years ago • 2 comments

Read the original file for comparing/detecting newline (#4236)

Closes #4097

The code base diverged enough where a simple cherry-pick wasn't possible, but implementing the logic to read the input file when NewlineStyle::Auto was simple enough to implement.

New tests were added to hopefully prevent regressions.

ytmimi avatar Jul 12 '22 02:07 ytmimi

I want to note that the original PR removes code that this PR does not since they take slightly different approaches to how apply_newline_style is called / updated. I haven't looked too deeply into it, but I wonder if we can remove similar code after making these changes.

I was also wondering if we had any tests in test/source that used crlf newlines. I was thinking it might be a good idea to add at least one system test for this backport to ensure that we maintain the newline style of the original input text regardless of the platform when newline_style=Auto

ytmimi avatar Jul 12 '22 04:07 ytmimi

because of updates made to apply_newline_style, there will be some minor conflicts with #5418 depending on which backport PR gets merged first.

ytmimi avatar Jul 12 '22 05:07 ytmimi