Allow single-line after let with IndentPolicyLeft

pull/66/head
Lennart Spitzner 2017-11-27 23:27:33 +01:00
parent d9155e240d
commit 882a3b1a7a
3 changed files with 20 additions and 25 deletions

View File

@ -532,8 +532,7 @@ func = do
#test let #test let
func = do func = do
let let x = 13
x = 13
stmt x stmt x
@ -1020,8 +1019,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
| not hasComments | not hasComments
, [(guards, body, _bodyRaw)] <- [clauseDocs] , [(guards, body, _bodyRaw)] <- [clauseDocs]
, let , let guardPart = singleLineGuardsDoc guards
guardPart = singleLineGuardsDoc guards
, wherePart <- case mWhereDocs of , wherePart <- case mWhereDocs of
Nothing -> return @[] $ docEmpty Nothing -> return @[] $ docEmpty
Just [w] -> return @[] $ docSeq Just [w] -> return @[] $ docSeq
@ -1042,8 +1040,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]
, let , let guardPart = singleLineGuardsDoc guards
guardPart = singleLineGuardsDoc guards
, Data.Maybe.isJust mWhereDocs , Data.Maybe.isJust mWhereDocs
] ]
++ -- two-line solution + where in next line(s) ++ -- two-line solution + where in next line(s)
@ -1055,8 +1052,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]
, let , let guardPart = singleLineGuardsDoc guards
guardPart = singleLineGuardsDoc guards
] ]
#test comment-testcase-17 #test comment-testcase-17

View File

@ -541,7 +541,7 @@ layoutExpr lexpr@(L _ expr) = do
-- comments before the first let item are moved horizontally with it. -- comments before the first let item are moved horizontally with it.
docSetIndentLevel $ case mBindDocs of docSetIndentLevel $ case mBindDocs of
Just [bindDoc] -> docAltFilter Just [bindDoc] -> docAltFilter
[ ( indentPolicy /= IndentPolicyLeft [ ( True
, docSeq , docSeq
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
, appSep $ docForceSingleline $ return bindDoc , appSep $ docForceSingleline $ return bindDoc

View File

@ -54,22 +54,22 @@ layoutStmt lstmt@(L _ stmt) = do
-- indeed allowed. -- indeed allowed.
-- heh. -- heh.
Just [] -> docLit $ Text.pack "let" -- this probably never happens Just [] -> docLit $ Text.pack "let" -- this probably never happens
Just [bindDoc] -> docAltFilter Just [bindDoc] -> docAlt
[ -- let bind = expr [ -- let bind = expr
( indentPolicy /= IndentPolicyLeft docCols
, docCols
ColDoLet ColDoLet
[ appSep $ docLit $ Text.pack "let" [ appSep $ docLit $ Text.pack "let"
, docSetBaseAndIndent $ return bindDoc , ( if indentPolicy == IndentPolicyLeft
] then docForceSingleline
else docSetBaseAndIndent
) )
$ return bindDoc
]
, -- let , -- let
-- bind = expr -- bind = expr
( True docAddBaseY BrIndentRegular $ docPar
, docAddBaseY BrIndentRegular $ docPar
(docLit $ Text.pack "let") (docLit $ Text.pack "let")
(docSetBaseAndIndent $ return bindDoc) (docSetBaseAndIndent $ return bindDoc)
)
] ]
Just bindDocs -> docAltFilter Just bindDocs -> docAltFilter
[ -- let aaa = expra [ -- let aaa = expra
@ -107,9 +107,8 @@ layoutStmt lstmt@(L _ stmt) = do
-- stmt2 -- stmt2
-- stmt3 -- stmt3
( True ( True
, docAddBaseY BrIndentRegular $ docPar , docAddBaseY BrIndentRegular
(docLit (Text.pack "rec")) $ docPar (docLit (Text.pack "rec")) (docLines $ layoutStmt <$> stmts)
(docLines $ layoutStmt <$> stmts)
) )
] ]
BodyStmt expr _ _ _ -> do BodyStmt expr _ _ _ -> do