Fix let-in comment placement bug (fixes #110)
parent
bdd3b155f3
commit
0845142727
|
@ -538,8 +538,16 @@ cs0 = 0 : [ c / Interval n | c <- cs | n <- [1..] ]
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost
|
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost
|
||||||
|
|
||||||
#test issue 111
|
#test issue 110
|
||||||
|
main = -- a
|
||||||
|
let --b
|
||||||
|
x = 1 -- x
|
||||||
|
y = 2 -- y
|
||||||
|
in do
|
||||||
|
print x
|
||||||
|
print y
|
||||||
|
|
||||||
|
#test issue 111
|
||||||
alternatives :: Parser (Maybe Text)
|
alternatives :: Parser (Maybe Text)
|
||||||
alternatives =
|
alternatives =
|
||||||
alternativeOne -- first try this one
|
alternativeOne -- first try this one
|
||||||
|
|
|
@ -543,7 +543,9 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
(layoutPatternBindFinal Nothing binderDoc Nothing clauseDocs Nothing hasComments)
|
(layoutPatternBindFinal Nothing binderDoc Nothing clauseDocs Nothing hasComments)
|
||||||
HsLet binds exp1 -> do
|
HsLet binds exp1 -> do
|
||||||
expDoc1 <- docSharedWrapper layoutExpr exp1
|
expDoc1 <- docSharedWrapper layoutExpr exp1
|
||||||
mBindDocs <- layoutLocalBinds binds
|
-- We jump through some ugly hoops here to ensure proper sharing.
|
||||||
|
mBindDocs <- mapM (fmap (fmap return) . docWrapNodeRest lexpr . return)
|
||||||
|
=<< layoutLocalBinds binds
|
||||||
let
|
let
|
||||||
ifIndentLeftElse :: a -> a -> a
|
ifIndentLeftElse :: a -> a -> a
|
||||||
ifIndentLeftElse x y =
|
ifIndentLeftElse x y =
|
||||||
|
@ -560,7 +562,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
Just [bindDoc] -> docAlt
|
Just [bindDoc] -> docAlt
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, appSep $ docForceSingleline $ return bindDoc
|
, appSep $ docForceSingleline $ bindDoc
|
||||||
, appSep $ docLit $ Text.pack "in"
|
, appSep $ docLit $ Text.pack "in"
|
||||||
, docForceSingleline $ expDoc1
|
, docForceSingleline $ expDoc1
|
||||||
]
|
]
|
||||||
|
@ -569,12 +571,12 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, ifIndentLeftElse docForceSingleline docSetBaseAndIndent
|
, ifIndentLeftElse docForceSingleline docSetBaseAndIndent
|
||||||
$ return bindDoc
|
$ bindDoc
|
||||||
]
|
]
|
||||||
, docAddBaseY BrIndentRegular
|
, docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetBaseAndIndent $ return bindDoc)
|
(docSetBaseAndIndent $ bindDoc)
|
||||||
]
|
]
|
||||||
, docAlt
|
, docAlt
|
||||||
[ docSeq
|
[ docSeq
|
||||||
|
@ -607,7 +609,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
[ docAddBaseY BrIndentRegular
|
[ docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
|
(docSetBaseAndIndent $ docLines $ bindDocs)
|
||||||
, docSeq
|
, docSeq
|
||||||
[ docLit $ Text.pack "in "
|
[ docLit $ Text.pack "in "
|
||||||
, docAddBaseY BrIndentRegular $ expDoc1
|
, docAddBaseY BrIndentRegular $ expDoc1
|
||||||
|
@ -618,7 +620,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
, docLines
|
, docLines
|
||||||
[ docSeq
|
[ docSeq
|
||||||
[ appSep $ docLit $ Text.pack "let"
|
[ appSep $ docLit $ Text.pack "let"
|
||||||
, docSetBaseAndIndent $ docLines $ return <$> bindDocs
|
, docSetBaseAndIndent $ docLines $ bindDocs
|
||||||
]
|
]
|
||||||
, docSeq
|
, docSeq
|
||||||
[ appSep $ docLit $ Text.pack "in "
|
[ appSep $ docLit $ Text.pack "in "
|
||||||
|
@ -631,7 +633,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
[ docAddBaseY BrIndentRegular
|
[ docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "let")
|
(docLit $ Text.pack "let")
|
||||||
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
|
(docSetBaseAndIndent $ docLines $ bindDocs)
|
||||||
, docAddBaseY BrIndentRegular
|
, docAddBaseY BrIndentRegular
|
||||||
$ docPar
|
$ docPar
|
||||||
(docLit $ Text.pack "in")
|
(docLit $ Text.pack "in")
|
||||||
|
|
Loading…
Reference in New Issue