Fix a missing comment case with MultiWayIf

ghc92
Lennart Spitzner 2023-05-29 22:59:16 +02:00
parent 03e578f72c
commit 4ed3a2f53d
2 changed files with 20 additions and 10 deletions

View File

@ -14,3 +14,10 @@ func = do
bar $ if bar $ if
| cond1 -> loooooooooooooooooooooooooooooong expr1 | cond1 -> loooooooooooooooooooooooooooooong expr1
| cond2 -> loooooooooooooooooooooooooooooong expr2 | cond2 -> loooooooooooooooooooooooooooooong expr2
#test multiwayif comment between cases
func = do
if
| abc -> yes
-- | test comment
| _ -> no

View File

@ -493,16 +493,19 @@ layoutExpr lexpr@(L _ expr) = do
|| any (\(L _ (GRHS gEpAnn _ _)) -> hasAnyCommentsBelow gEpAnn) cases || any (\(L _ (GRHS gEpAnn _ _)) -> hasAnyCommentsBelow gEpAnn) cases
let posIf = obtainAnnPos epAnn AnnIf let posIf = obtainAnnPos epAnn AnnIf
layouters <- mAsk layouters <- mAsk
docSetParSpacing $ docAddBaseY BrIndentRegular $ docPar docHandleComms epAnn
(docHandleComms posIf $ docLit $ Text.pack "if") $ docSetParSpacing
(layout_patternBindFinal layouters $ docAddBaseY BrIndentRegular
Nothing $ docPar
binderDoc (docHandleComms posIf $ docLit $ Text.pack "if")
Nothing (layout_patternBindFinal layouters
(Right cases) Nothing
(id, Nothing) binderDoc
hasComments Nothing
) (Right cases)
(id, Nothing)
hasComments
)
HsLet epAnn binds exp1 -> docHandleComms epAnn $ do HsLet epAnn binds exp1 -> docHandleComms epAnn $ do
let AnnsLet spanLet spanIn = anns epAnn let AnnsLet spanLet spanIn = anns epAnn
let hasComments = hasAnyCommentsBelow lexpr let hasComments = hasAnyCommentsBelow lexpr