Retain comments after lambdacase and at record fields

Lennart Spitzner 2023-05-20 16:09:01 +02:00
parent 22a658e794
commit cf426f2040
1 changed files with 13 additions and 10 deletions

View File

@ -124,19 +124,22 @@ layoutExpr lexpr@(L _ expr) = do
docSetParSpacing
$ docAddBaseY BrIndentRegular
$ (docLit $ Text.pack "\\case {}")
HsLamCase _ (MG _ lmatches@(L _ matches) _) -> do
HsLamCase epAnn (MG _ lmatches@(L _ matches) _) -> do
binderDoc <- docLit $ Text.pack "->"
layouters <- mAsk
funcPatDocs <-
layout_patternBind layouters Nothing binderDoc `mapM` matches
docSetParSpacing $ docAddBaseY BrIndentRegular $ docPar
(docLit $ Text.pack "\\case")
( docSetBaseAndIndent
$ docNonBottomSpacing
$ docHandleComms lmatches
$ docLines
$ return <$> funcPatDocs
)
docSetParSpacing
$ docAddBaseY BrIndentRegular
$ docHandleComms epAnn
$ docPar
(docLit $ Text.pack "\\case")
( docSetBaseAndIndent
$ docNonBottomSpacing
$ docHandleComms lmatches
$ docLines
$ return <$> funcPatDocs
)
HsApp _ exp1 _ -> do
let gather
:: [(EpAnnCO, LHsExpr GhcPs)]
@ -1015,7 +1018,7 @@ recordExpression dotdot wrapO wrapDD wrapC indentPolicy _lexpr nameDoc nameLayou
[AddCommaAnn span] -> Just $ epaLocationRealSrcSpanStart span
_ -> Nothing
SrcSpanAnn EpAnnNotUsed _ -> Nothing
fnameDoc <- shareDoc $ nameLayouter nameThing
fnameDoc <- shareDoc $ docHandleComms fEpAnn $ nameLayouter nameThing
if pun
then pure $ Left (posStart, fnameDoc)
else do