Fix indentation (comments) after "if" (Fixes #167)
parent
1290e8cd27
commit
621e00bf3f
|
@ -516,6 +516,20 @@ myTupleSection =
|
|||
func = (lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd
|
||||
, lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd)
|
||||
|
||||
#test comment-after-then
|
||||
foo = if True
|
||||
then
|
||||
-- iiiiii
|
||||
"a "
|
||||
else
|
||||
"b "
|
||||
|
||||
#test comment-after-if-else-do
|
||||
func = if cond
|
||||
then pure 42
|
||||
else do
|
||||
-- test
|
||||
abc
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -417,13 +417,11 @@ layoutIndentLevelPushCur = do
|
|||
(Right{}, Just j ) -> j
|
||||
(Right{}, Nothing) -> 0
|
||||
layoutIndentLevelPushInternal y
|
||||
layoutBaseYPushInternal y
|
||||
|
||||
layoutIndentLevelPop
|
||||
:: (MonadMultiState LayoutState m, MonadMultiWriter (Seq String) m) => m ()
|
||||
layoutIndentLevelPop = do
|
||||
traceLocal ("layoutIndentLevelPop")
|
||||
layoutBaseYPopInternal
|
||||
layoutIndentLevelPopInternal
|
||||
-- why are comment indentations relative to the previous indentation on
|
||||
-- the first node of an additional indentation, and relative to the outer
|
||||
|
|
|
@ -563,7 +563,7 @@ layoutExpr lexpr@(L _ expr) = do
|
|||
IndentPolicyFree -> BrIndentSpecial 3
|
||||
-- TODO: some of the alternatives (especially last and last-but-one)
|
||||
-- overlap.
|
||||
runFilteredAlternative $ do
|
||||
docSetIndentLevel $ runFilteredAlternative $ do
|
||||
-- if _ then _ else _
|
||||
addAlternativeCond (not hasComments)
|
||||
$ docSeq
|
||||
|
|
|
@ -128,6 +128,10 @@ transformSimplifyFloating = stepBO .> stepFull
|
|||
Just $ BDBaseYPop (BDAddBaseY ind x)
|
||||
BDAddBaseY ind (BDDebug s x) ->
|
||||
Just $ BDDebug s (BDAddBaseY ind x)
|
||||
BDAddBaseY ind (BDIndentLevelPop x) ->
|
||||
Just $ BDIndentLevelPop (BDAddBaseY ind x)
|
||||
BDAddBaseY ind (BDIndentLevelPushCur x) ->
|
||||
Just $ BDIndentLevelPushCur (BDAddBaseY ind x)
|
||||
_ -> Nothing
|
||||
stepBO :: BriDoc -> BriDoc
|
||||
stepBO = -- traceFunctionWith "stepBO" (show . briDocToDocWithAnns) (show . briDocToDocWithAnns) $
|
||||
|
|
Loading…
Reference in New Issue