Remove context sensitive let indentation when IndentPolicyLeft

Let expressions with multiple bindings automattically indent and pull
left

```
let
  a = b
  c = d
in foo bar baz
```

```
let
  a = b
  c = d
in
  foo bar baz
```

```
let
  a = b
  c = d
in foo
  bar
  baz
```

```
let
  a = b
  c = d
in
  foo
    bar
    baz
```
pull/66/head
Evan Rutledge Borden 2017-09-21 21:47:30 -04:00 committed by Lennart Spitzner
parent bdf8769913
commit ce41178df5
1 changed files with 57 additions and 20 deletions

View File

@ -567,28 +567,65 @@ layoutExpr lexpr@(L _ expr) = do
(docSetBaseY $ expDoc1) (docSetBaseY $ expDoc1)
] ]
] ]
Just bindDocs@(_:_) -> docAlt Just bindDocs@(_:_) -> docAlt $
[ docLines case indentPolicy of
[ docSeq IndentPolicyLeft ->
[ appSep $ docLit $ Text.pack "let" --either
, docSetBaseAndIndent $ docLines $ return <$> bindDocs -- let
-- a = b
-- c = d
-- in foo
-- bar
-- baz
--or
-- let
-- a = b
-- c = d
-- in
-- fooooooooooooooooooo
[ docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docSeq
[ docLit $ Text.pack "in "
, docAddBaseY BrIndentRegular $ expDoc1
]
]
, docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
]
] ]
, docSeq _ ->
[ appSep $ docLit $ Text.pack "in " [ docLines
, docSetBaseY $ expDoc1 [ docSeq
[ appSep $ docLit $ Text.pack "let"
, docSetBaseAndIndent $ docLines $ return <$> bindDocs
]
, docSeq
[ appSep $ docLit $ Text.pack "in "
, docSetBaseY $ expDoc1
]
]
, docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
]
] ]
]
, docLines
[ docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs)
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "in")
(docSetBaseY $ expDoc1)
]
]
_ -> docSeq [appSep $ docLit $ Text.pack "let in", expDoc1] _ -> docSeq [appSep $ docLit $ Text.pack "let in", expDoc1]
-- docSeq [appSep $ docLit "let in", expDoc1] -- docSeq [appSep $ docLit "let in", expDoc1]
HsDo DoExpr (L _ stmts) _ -> do HsDo DoExpr (L _ stmts) _ -> do