Skip to content

Commit

Permalink
Increase list length limit to 6 in functions
Browse files Browse the repository at this point in the history
This fixes the poor formatting of the last remaining cases of
mkRenamedOptionModule.

We're not removing the line length limit completely because this code
path doesn't enforce the line length limit.

Co-Authored-By: piegames <git@piegames.de>
  • Loading branch information
infinisil and piegamesde committed Nov 26, 2024
1 parent 33d5491 commit 07c484f
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 =
| length (unItems items) <= 6 && 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 07c484f

Please sign in to comment.