Remove 3 space special case from HsIf when IndentPolicyLeft

```
if foo
   bar
then
  baz
```

becomes

```
if foo
  bar
then
  baz
```
pull/66/head
Evan Rutledge Borden 2017-09-21 21:44:10 -04:00 committed by Lennart Spitzner
parent 88cbaf813a
commit bdf8769913
1 changed files with 7 additions and 3 deletions

View File

@ -415,6 +415,10 @@ layoutExpr lexpr@(L _ expr) = do
thenExprDoc <- docSharedWrapper layoutExpr thenExpr thenExprDoc <- docSharedWrapper layoutExpr thenExpr
elseExprDoc <- docSharedWrapper layoutExpr elseExpr elseExprDoc <- docSharedWrapper layoutExpr elseExpr
hasComments <- hasAnyCommentsBelow lexpr hasComments <- hasAnyCommentsBelow lexpr
let maySpecialIndent =
case indentPolicy of
IndentPolicyLeft -> BrIndentRegular
_ -> BrIndentSpecial 3
docAltFilter docAltFilter
[ -- if _ then _ else _ [ -- if _ then _ else _
(,) (not hasComments) (,) (not hasComments)
@ -443,7 +447,7 @@ layoutExpr lexpr@(L _ expr) = do
$ docSetParSpacing $ docSetParSpacing
$ docAddBaseY BrIndentRegular $ docAddBaseY BrIndentRegular
$ docPar $ docPar
( docAddBaseY (BrIndentSpecial 3) ( docAddBaseY maySpecialIndent
$ docSeq $ docSeq
[ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if" [ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if"
, docNodeAnnKW lexpr (Just AnnIf) $ docForceSingleline ifExprDoc , docNodeAnnKW lexpr (Just AnnIf) $ docForceSingleline ifExprDoc
@ -483,7 +487,7 @@ layoutExpr lexpr@(L _ expr) = do
(,) True (,) True
$ docAddBaseY BrIndentRegular $ docAddBaseY BrIndentRegular
$ docPar $ docPar
( docAddBaseY (BrIndentSpecial 3) ( docAddBaseY maySpecialIndent
$ docSeq $ docSeq
[ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if" [ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if"
, docNodeAnnKW lexpr (Just AnnIf) $ ifExprDoc , docNodeAnnKW lexpr (Just AnnIf) $ ifExprDoc
@ -506,7 +510,7 @@ layoutExpr lexpr@(L _ expr) = do
, (,) True , (,) True
$ docSetBaseY $ docSetBaseY
$ docLines $ docLines
[ docAddBaseY (BrIndentSpecial 3) [ docAddBaseY maySpecialIndent
$ docSeq $ docSeq
[ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if" [ docNodeAnnKW lexpr Nothing $ appSep $ docLit $ Text.pack "if"
, docNodeAnnKW lexpr (Just AnnIf) $ ifExprDoc , docNodeAnnKW lexpr (Just AnnIf) $ ifExprDoc