Fix do let comment indentation problems

pull/3/head
Lennart Spitzner 2016-08-11 23:01:21 +02:00
parent 0a41843efd
commit 55709c9b17
2 changed files with 19 additions and 18 deletions

View File

@ -627,3 +627,13 @@ regressionTests = do
RepoLocal { abc } -> return () RepoLocal { abc } -> return ()
RepoLocal{} -> return () RepoLocal{} -> return ()
|] |]
it "do let comment indentation level problem" $ do
roundTripEqual $
[text|
func = do
let (primaryPkg, otherPkgs) = selectPrimaryLocalPackage pwd pkgs'
(bproblems, x) = resolveBuildTargets primaryPkg otherPkgs utargets''
-- default local dir target if there's no given target
utargets'' = "foo"
return ()
|]

View File

@ -62,25 +62,16 @@ layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of
(docLit $ Text.pack "let") (docLit $ Text.pack "let")
(docSetIndentLevel $ return bindDoc) (docSetIndentLevel $ return bindDoc)
] ]
Just bindDocs@(bindDoc1:bindDocr) -> do Just bindDocs -> docAlt
-- TODO: the indentation here is screwed up. needs docSetIndentLevel and [ docSeq
-- SetBaseY based layouting, not cols. [ appSep $ docLit $ Text.pack "let"
docSetBaseY $ docAlt , docSetIndentLevel $ docLines $ return <$> bindDocs
[ docLines
$ (docCols ColDoLet
[ appSep $ docLit $ Text.pack "let"
, docSetIndentLevel $ return bindDoc1
])
: (bindDocr <&> \bindDoc ->
docCols ColDoLet
[ docEnsureIndent (BrIndentSpecial 4) docEmpty
, docSetIndentLevel $ return bindDoc
])
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetIndentLevel $ docLines $ return <$> bindDocs)
] ]
, docAddBaseY BrIndentRegular
$ docPar
(docLit $ Text.pack "let")
(docSetIndentLevel $ docLines $ return <$> bindDocs)
]
BodyStmt expr _ _ _ -> do BodyStmt expr _ _ _ -> do
expDoc <- docSharedWrapper layoutExpr expr expDoc <- docSharedWrapper layoutExpr expr
docAddBaseY BrIndentRegular $ expDoc docAddBaseY BrIndentRegular $ expDoc