From 55709c9b17ac741665d12ef350b819572d577e69 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Thu, 11 Aug 2016 23:01:21 +0200 Subject: [PATCH] Fix do let comment indentation problems --- src-unittests/IdentityTests.hs | 10 +++++++ .../Haskell/Brittany/Layouters/Stmt.hs | 27 +++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src-unittests/IdentityTests.hs b/src-unittests/IdentityTests.hs index 482a357..fa5bd82 100644 --- a/src-unittests/IdentityTests.hs +++ b/src-unittests/IdentityTests.hs @@ -627,3 +627,13 @@ regressionTests = do RepoLocal { abc } -> 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 () + |] diff --git a/src/Language/Haskell/Brittany/Layouters/Stmt.hs b/src/Language/Haskell/Brittany/Layouters/Stmt.hs index f5c2815..af10720 100644 --- a/src/Language/Haskell/Brittany/Layouters/Stmt.hs +++ b/src/Language/Haskell/Brittany/Layouters/Stmt.hs @@ -62,25 +62,16 @@ layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of (docLit $ Text.pack "let") (docSetIndentLevel $ return bindDoc) ] - Just bindDocs@(bindDoc1:bindDocr) -> do - -- TODO: the indentation here is screwed up. needs docSetIndentLevel and - -- SetBaseY based layouting, not cols. - docSetBaseY $ docAlt - [ 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) + Just bindDocs -> docAlt + [ docSeq + [ appSep $ docLit $ Text.pack "let" + , docSetIndentLevel $ docLines $ return <$> bindDocs ] + , docAddBaseY BrIndentRegular + $ docPar + (docLit $ Text.pack "let") + (docSetIndentLevel $ docLines $ return <$> bindDocs) + ] BodyStmt expr _ _ _ -> do expDoc <- docSharedWrapper layoutExpr expr docAddBaseY BrIndentRegular $ expDoc