1
1
mirror of https://github.com/google/ormolu.git synced 2024-10-26 08:31:36 +03:00

Use braces when placing $ on the same line

This commit is contained in:
Utku Demir 2019-11-17 18:44:55 +13:00 committed by Mark Karpov
parent cd6c7521c1
commit 81e60bb342
3 changed files with 18 additions and 7 deletions

View File

@ -16,3 +16,7 @@ foo =
bar
$ baz
$ quux
x =
case l of { A -> B } $
case q of r -> s

View File

@ -16,3 +16,7 @@ foo =
bar
$ baz
$ quux
x =
case l of { A -> B } $
case q of r -> s

View File

@ -1259,21 +1259,24 @@ p_exprOpTree isDollarSpecial s (OpBranch x op y) = do
gotDollar = case getOpName (unLoc op) of
Just rname -> mkVarOcc "$" == (rdrNameOcc rname)
_ -> False
switchLayout [opTreeLoc x]
$ ub
$ p_exprOpTree (not gotDollar) s x
lhs =
switchLayout [opTreeLoc x] $
p_exprOpTree (not gotDollar) s x
let p_op = located op (opWrapper . p_hsExpr)
p_y = switchLayout [opTreeLoc y] (p_exprOpTree True N y)
if isDollarSpecial && gotDollar && placement == Normal && isOneLineSpan (opTreeLoc x)
then do
useBraces lhs
space
p_op
breakpoint
inci p_y
else placeHanging placement $ do
p_op
space
p_y
else do
ub lhs
placeHanging placement $ do
p_op
space
p_y
-- | Get annotations for the enclosing element.
getEnclosingAnns :: R [AnnKeywordId]