Skip to content

Commit

Permalink
Merge pull request #249 from NixOS/fix-weird-selection
Browse files Browse the repository at this point in the history
Fix selections getting expanded too liberally
  • Loading branch information
infinisil authored Aug 30, 2024
2 parents 625158a + 59e986d commit 458402c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,11 @@ instance Pretty Parameter where
-- then start on a new line instead".
prettyApp :: Bool -> Doc -> Bool -> Expression -> Expression -> Doc
prettyApp indentFunction pre hasPost f a =
let absorbApp (Application f' a') = group' Transparent (absorbApp f') <> line <> nest (group' Priority a')
let -- This is very hacky, but selections shouldn't be in a priority group,
-- because if they get expanded before anything else,
-- only the `.`-and-after part gets to a new line, which looks very odd
absorbApp (Application f' a'@(Term Selection{})) = group' Transparent (absorbApp f') <> line <> nest (group' RegularG a')
absorbApp (Application f' a') = group' Transparent (absorbApp f') <> line <> nest (group' Priority a')
absorbApp expr
| indentFunction && null comment' = nest $ group' RegularG $ line' <> pretty expr
| otherwise = pretty expr
Expand Down
5 changes: 5 additions & 0 deletions test/correct/regression-207.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
rust-channel-of-version =
assertEq (rustChannelOf { channel = "1.48.0"; }).rustc
stable."1.48.0".rustc;
}

0 comments on commit 458402c

Please sign in to comment.