nix-community / nixpkgs-fmt

Nix code formatter for nixpkgs [maintainer=@zimbatm]
https://nix-community.github.io/nixpkgs-fmt/
Apache License 2.0
581 stars 34 forks source link

multiline string content gets modified, altering outputs #325

Open srhb opened 7 months ago

srhb commented 7 months ago

Describe the bug (Note that whitespace is the crux of the issue here, if you're viewing in a browser you may have trouble seeing the differences)

Output files differ because whitespace is altered within multiline strings.

https://gist.github.com/srhb/cfb85687f9cb9ad961079960d7d10af8



**To Reproduce**
Steps to reproduce the behavior:

`unformatted.nix` is the raw nix file.
`formatted.nix` is the same file after running `nixpkgs-fmt` from this devShell at 7301bc9f2ba29fe693c04cbcaa12110eb9685c71

result-unformatted is the resultant text-file from nix-build'ing `unformatted.nix`
result-formatted is the resultant text-file from nix-build'ing `formatted.nix`

**Expected behavior**
The outputs are the same

**System information**

* `nixpkgs-fmt --version`
nixpkgs-fmt 1.3.0

**Additional context**
srhb commented 7 months ago

Hmm, I wonder if this is actually an rnix problem.

srhb commented 7 months ago

Oh, and now I realize you have a nifty automated test thingy.

https://github.com/srhb/nixpkgs-fmt/tree/try-auto-test-good-bad-whitespace-in-multiline

cargo test should show the test failure in that branch's devShell