Fix comments in tuples being dropped (fixes #37)

pull/132/head
Lennart Spitzner 2018-03-23 16:55:09 +01:00
parent d634d34ff1
commit a003b932a9
2 changed files with 16 additions and 2 deletions

View File

@ -373,6 +373,16 @@ runBrittany tabSize text = do
}
parsePrintModule config text
#test issue 37
foo =
( a
, -- comment1
b
-- comment2
, c
)
#test issue 38
{-# LANGUAGE TypeApplications #-}

View File

@ -346,8 +346,12 @@ layoutExpr lexpr@(L _ expr) = do
rightDoc <- docSharedWrapper layoutExpr right
docSeq [opDoc, docSeparator, rightDoc]
ExplicitTuple args boxity -> do
let argExprs = fmap (\case (L _ (Present e)) -> Just e; (L _ (Missing PlaceHolder)) -> Nothing) args
argDocs <- docSharedWrapper (maybe docEmpty layoutExpr) `mapM` argExprs
let argExprs = args <&> \arg -> case arg of
(L _ (Present e)) -> (arg, Just e);
(L _ (Missing PlaceHolder)) -> (arg, Nothing)
argDocs <- forM argExprs
$ docSharedWrapper
$ \(arg, exprM) -> docWrapNode arg $ maybe docEmpty layoutExpr exprM
hasComments <- hasAnyCommentsBelow lexpr
let (openLit, closeLit) = case boxity of
Boxed -> (docLit $ Text.pack "(", docLit $ Text.pack ")")