diff --git a/src/Nixfmt/Pretty.hs b/src/Nixfmt/Pretty.hs index 88892ea2..120ef92b 100644 --- a/src/Nixfmt/Pretty.hs +++ b/src/Nixfmt/Pretty.hs @@ -127,10 +127,8 @@ instance Pretty Binder where pretty (Inherit inherit Nothing ids semicolon) = group $ pretty inherit - <> ( if null ids - then pretty semicolon - else sep <> nest (sepBy sep ids <> nosep <> pretty semicolon) - ) + <> sep + <> nest (sepBy sep ids <> nosep <> pretty semicolon) where -- Only allow a single line if it's already on a single line and has few enough elements (sep, nosep) = if sourceLine inherit == sourceLine semicolon && length ids < 4 then (line, line') else (hardline, hardline) @@ -140,13 +138,10 @@ instance Pretty Binder where pretty inherit <> nest ( group' RegularG (line <> pretty source) - <> if null ids - then pretty semicolon - else - sep - <> sepBy sep ids - <> nosep - <> pretty semicolon + <> sep + <> sepBy sep ids + <> nosep + <> pretty semicolon ) where -- Only allow a single line if it's already on a single line and has few enough elements diff --git a/test/diff/inherit/out.nix b/test/diff/inherit/out.nix index a5b01067..a15a258d 100644 --- a/test/diff/inherit/out.nix +++ b/test/diff/inherit/out.nix @@ -1,7 +1,7 @@ [ { # empty inherit o.O - inherit; + inherit ; inherit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; } { @@ -83,7 +83,8 @@ } { - inherit; + inherit + ; inherit a ; diff --git a/test/diff/inherit_from/out.nix b/test/diff/inherit_from/out.nix index 62225bbc..f53312f6 100644 --- a/test/diff/inherit_from/out.nix +++ b/test/diff/inherit_from/out.nix @@ -1,7 +1,7 @@ [ { # empty inherit o.O - inherit (geany.meta); + inherit (geany.meta) ; inherit (builtins) pathExists readFile @@ -572,9 +572,11 @@ ; } { - inherit ({ }); - inherit ({ }); - inherit ({ }); + inherit ({ }) ; + inherit ({ }) + ; + inherit ({ }) + ; inherit ({ }) a; inherit ({ })