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 ## this testcase is not about idempotency, but about _how_ the output differs
## from the input; i cannot really express this yet with the current ## from the input; i cannot really express this yet with the current
## test-suite. ## test-suite.

View File

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