From 64d35408ab17a3c1b18b4a0cfef250debdb994c8 Mon Sep 17 00:00:00 2001 From: piegames Date: Mon, 2 Dec 2024 22:38:40 +0100 Subject: [PATCH] isSimple: Mark numbers and other tokens as simple Identifiers already were, that the others weren't was a mere oversight. Fixes #203 --- src/Nixfmt/Pretty.hs | 3 +++ test/diff/apply_with_lists/out-pure.nix | 13 ++----------- test/diff/apply_with_lists/out.nix | 13 ++----------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index ec72cf8..1f03c82 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -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 diff --git a/test/diff/apply_with_lists/out-pure.nix b/test/diff/apply_with_lists/out-pure.nix index f13e62b..51dedb7 100644 --- a/test/diff/apply_with_lists/out-pure.nix +++ b/test/diff/apply_with_lists/out-pure.nix @@ -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 ] diff --git a/test/diff/apply_with_lists/out.nix b/test/diff/apply_with_lists/out.nix index fb2a655..9ed360b 100644 --- a/test/diff/apply_with_lists/out.nix +++ b/test/diff/apply_with_lists/out.nix @@ -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 ]