Skip to content

Commit

Permalink
isSimple: Mark numbers and other tokens as simple
Browse files Browse the repository at this point in the history
Identifiers already were, that the others weren't was a mere oversight.

Fixes NixOS#203
  • Loading branch information
piegamesde committed Dec 2, 2024
1 parent 4200d2e commit 64d3540
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ isSimple (Term (SimpleString (LoneAnn _))) = True
isSimple (Term (IndentedString (LoneAnn _))) = True
isSimple (Term (Path (LoneAnn _))) = True
isSimple (Term (Token (LoneAnn (Identifier _)))) = True
isSimple (Term (Token (LoneAnn (Integer _)))) = True
isSimple (Term (Token (LoneAnn (Float _)))) = True
isSimple (Term (Token (LoneAnn (EnvPath _)))) = True
isSimple (Term (Selection t selectors def)) =
isSimple (Term t) && all isSimpleSelector selectors && isNothing def
isSimple (Term (Parenthesized (LoneAnn _) e (LoneAnn _))) = isSimple e
Expand Down
13 changes: 2 additions & 11 deletions test/diff/apply_with_lists/out-pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@
name
)
(replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ])
(lists.removePrefix
[
1
2
]
[ ]
)
(lists.removePrefix [ 1 2 ] [ ])
(lists.removePrefix aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[
1
2
]
[ 1 2 ]
[ ]
)
(builtins.replaceStrings [ "@NIX_STORE_VERITY@" ] [ partitionTypes.usr-verity ]
Expand Down
13 changes: 2 additions & 11 deletions test/diff/apply_with_lists/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@
name
)
(replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ])
(lists.removePrefix
[
1
2
]
[ ]
)
(lists.removePrefix [ 1 2 ] [ ])
(lists.removePrefix aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[
1
2
]
[ 1 2 ]
[ ]
)
(builtins.replaceStrings [ "@NIX_STORE_VERITY@" ] [ partitionTypes.usr-verity ]
Expand Down

0 comments on commit 64d3540

Please sign in to comment.