Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selections getting expanded too liberally #249

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}