Skip to content

Commit

Permalink
Merge pull request #219 from NixOS/fix-idempotency-attribute-par-comm…
Browse files Browse the repository at this point in the history
…ents

Fix non-idempotent comments in attribute parameters
  • Loading branch information
infinisil authored Jul 12, 2024
2 parents a98ea65 + 6cb8544 commit 278b7ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ moveParamsComments
-- # comment
-- , name2
( (ParamAttr name maybeDefault (Just (Ann trivia comma Nothing)))
: (ParamAttr (Ann trivia' name' Nothing) maybeDefault' maybeComma')
: (ParamAttr (Ann trivia' name' trailing') maybeDefault' maybeComma')
: xs
) =
ParamAttr name maybeDefault (Just (Ann [] comma Nothing))
: moveParamsComments (ParamAttr (Ann (trivia ++ trivia') name' Nothing) maybeDefault' maybeComma' : xs)
: moveParamsComments (ParamAttr (Ann (trivia ++ trivia') name' trailing') maybeDefault' maybeComma' : xs)
-- This may seem like a nonsensical case, but keep in mind that blank lines also count as comments (trivia)
moveParamsComments
-- , name
Expand Down
6 changes: 6 additions & 0 deletions test/diff/regression-218/in.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
foo
# bar
, baz # qux
}:
null
6 changes: 6 additions & 0 deletions test/diff/regression-218/out.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
foo,
# bar
baz, # qux
}:
null

0 comments on commit 278b7ee

Please sign in to comment.