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