diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index 1dd22d0..ae3e305 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -469,13 +469,18 @@ prettyApp indentFunction pre hasPost f a = post = if hasPost then line' else mempty in pretty comment' - <> case (f, a) of - -- When the two last arguments are lists, don't absorb the last one (absorbLast) - (Application _ (Term List{}), Term List{}) -> - renderSimple - (absorbApp (Application fWithoutComment a)) - (\fRendered -> group' RegularG fRendered) - (\fRendered -> group' RegularG $ fRendered <> post) + <> case (fWithoutComment, a) of + -- When the two last arguments are lists, render these specially (same as above) + -- Also no need to wrap in renderSimple here, because we know that these kinds of arguments + -- are never "simple" by definition. + (Application fWithoutCommandAndWithoutArg l1@(Term List{}), l2@(Term List{})) -> + group' RegularG $ + (pre <> group' Transparent (absorbApp fWithoutCommandAndWithoutArg)) + <> line + <> nest (group (absorbInner l1)) + <> line + <> nest (group (absorbInner l2)) + <> post _ -> renderSimple (absorbApp fWithoutComment) diff --git a/test/diff/apply_with_lists/out-pure.nix b/test/diff/apply_with_lists/out-pure.nix index c7f142a..edf22e6 100644 --- a/test/diff/apply_with_lists/out-pure.nix +++ b/test/diff/apply_with_lists/out-pure.nix @@ -62,7 +62,9 @@ ) (lib.mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ]) # This line is engineered to exactly hit the line length limit - (lib.mkRenamedOptionModule [ "hardware" "package234" ] [ "hardware" "graphics" ] + (lib.mkRenamedOptionModule + [ "hardware" "package234" ] + [ "hardware" "graphics" ] ) (mkRenamedOptionModule [ @@ -102,7 +104,9 @@ [ "Blue" "Flamingo" "Green" ] [ accent ] lib.checkListOfEnum - "${pname}: color variant" [ "Latte" "Frappe" "Macchiato" "Mocha" ] [ variant ] + "${pname}: color variant" + [ "Latte" "Frappe" "Macchiato" "Mocha" ] + [ variant ] ) (lib.switch [ coq.coq-version ssreflect.version ] diff --git a/test/diff/apply_with_lists/out.nix b/test/diff/apply_with_lists/out.nix index 2deef89..580e2b6 100644 --- a/test/diff/apply_with_lists/out.nix +++ b/test/diff/apply_with_lists/out.nix @@ -62,7 +62,9 @@ ) (lib.mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ]) # This line is engineered to exactly hit the line length limit - (lib.mkRenamedOptionModule [ "hardware" "package234" ] [ "hardware" "graphics" ] + (lib.mkRenamedOptionModule + [ "hardware" "package234" ] + [ "hardware" "graphics" ] ) (mkRenamedOptionModule [ @@ -106,7 +108,9 @@ ] [ accent ] lib.checkListOfEnum - "${pname}: color variant" [ "Latte" "Frappe" "Macchiato" "Mocha" ] [ variant ] + "${pname}: color variant" + [ "Latte" "Frappe" "Macchiato" "Mocha" ] + [ variant ] ) (lib.switch [ coq.coq-version ssreflect.version ]