Skip to content

Commit

Permalink
Remove single-line list length restriction
Browse files Browse the repository at this point in the history
This restriction doesn't appear to be necessary anymore, and is
the last remaining cause for `mkRenamedOptionModule`'s being formatted
poorly.
  • Loading branch information
infinisil committed Nov 26, 2024
1 parent ec04379 commit 7867adc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ prettyApp indentFunction pre hasPost f a =
-- If lists have only simple items, try to render them single-line instead of expanding
-- This is just a copy of the list rendering code, but with `sepBy line` instead of `sepBy hardline`
absorbInner (Term (List paropen@Ann{trailComment = post'} items parclose))
| length (unItems items) <= 4 && all (isSimple . Term) items =
| all (isSimple . Term) items =
pretty (paropen{trailComment = Nothing})
<> surroundWith sur (nest $ pretty post' <> sepBy line (unItems items))
<> pretty parclose
Expand Down
25 changes: 2 additions & 23 deletions test/diff/apply_with_lists/out-pure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@
[ ''\"'' "\\\\" ]
name
)
(replaceStrings
[
"@"
":"
"\\"
"["
"]"
]
[
"-"
"-"
"-"
""
""
]
)
(replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ])
(lists.removePrefix
[
1
Expand Down Expand Up @@ -67,13 +52,7 @@
[ "hardware" "graphics" ]
)
(mkRenamedOptionModule
[
"services"
"xserver"
"displayManager"
"sddm"
"enable"
]
[ "services" "xserver" "displayManager" "sddm" "enable" ]
[ "services" "displayManager" "sddm" "enable" ]
)
(map (
Expand Down
17 changes: 1 addition & 16 deletions test/diff/apply_with_lists/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@
[ ''\"'' "\\\\" ]
name
)
(replaceStrings
[
"@"
":"
"\\"
"["
"]"
]
[
"-"
"-"
"-"
""
""
]
)
(replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ])
(lists.removePrefix
[
1
Expand Down

0 comments on commit 7867adc

Please sign in to comment.