And one more touch to ExplicitList

pull/35/head
Lennart Spitzner 2017-05-02 16:31:51 +02:00
parent ca42178eff
commit c3dc3b6074
2 changed files with 13 additions and 5 deletions

View File

@ -761,6 +761,13 @@ autocheckCases =
)
]
#test issue 18c
func =
[ (abc, (1111, 1111))
, (def, (2, 2))
, foo -- comment
]
###############################################################################
###############################################################################
@ -770,8 +777,6 @@ autocheckCases =
###############################################################################
###############################################################################
## this testcase is not about idempotency, but about _how_ the output differs
## from the input; i cannot really express this yet with the current
## test-suite.

View File

@ -574,6 +574,7 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
unknownNodeError "HsDo{} no comp" lexpr
ExplicitList _ _ elems@(_:_) -> do
elemDocs <- elems `forM` docSharedWrapper layoutExpr
hasComments <- hasAnyCommentsBelow lexpr
case splitFirstLast elemDocs of
FirstLastEmpty -> docSeq
[ docLit $ Text.pack "["
@ -594,12 +595,14 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of
]
]
FirstLast e1 ems eN ->
docAlt
[ docSeq
docAltFilter
[ (,) (not hasComments)
$ docSeq
$ [docLit $ Text.pack "["]
++ List.intersperse docCommaSep (docForceSingleline <$> (e1:ems ++ [docNodeAnnKW lexpr (Just AnnOpenS) eN]))
++ [docLit $ Text.pack "]"]
, let
, (,) True
$ let
start = docCols ColList
[appSep $ docLit $ Text.pack "[", e1]
linesM = ems <&> \d ->