Skip to content

Commit

Permalink
Fix selections getting expanded too liberally
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Aug 30, 2024
1 parent 625158a commit 59e986d
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 59e986d

Please sign in to comment.