Skip to content

Commit

Permalink
Fix non-idempotent comments in attribute parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Jul 11, 2024
1 parent a98ea65 commit 6cb8544
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 6cb8544

Please sign in to comment.