Skip to content

Commit 8cb05e3

Browse files
committed
Revert "layoutWL: Don't let indentation result in trailing whitespace (#139)"
This reverts commit 9635a5d. Fixes #205.
1 parent a5342e4 commit 8cb05e3

2 files changed

Lines changed: 1 addition & 19 deletions

File tree

prettyprinter/src/Prettyprinter/Internal.hs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,15 +2073,7 @@ layoutWadlerLeijen
20732073
Empty -> best nl cc ds
20742074
Char c -> let !cc' = cc+1 in SChar c (best nl cc' ds)
20752075
Text l t -> let !cc' = cc+l in SText l t (best nl cc' ds)
2076-
Line -> let x = best i i ds
2077-
-- Don't produce indentation if there's no
2078-
-- following text on the same line.
2079-
-- This prevents trailing whitespace.
2080-
i' = case x of
2081-
SEmpty -> 0
2082-
SLine{} -> 0
2083-
_ -> i
2084-
in SLine i' x
2076+
Line -> SLine i (best i i ds)
20852077
FlatAlt x _ -> best nl cc (Cons i x ds)
20862078
Cat x y -> best nl cc (Cons i x (Cons i y ds))
20872079
Nest j x -> let !ij = i+j in best nl cc (Cons ij x ds)

prettyprinter/test/Testsuite/Main.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ tests = testGroup "Tests"
9090
[ testCase "Line" regressionUnboundedGroupedLine
9191
, testCase "Line within align" regressionUnboundedGroupedLineWithinAlign
9292
]
93-
, testCase "Indentation on otherwise empty lines results in trailing whitespace (#139)"
94-
indentationShouldntCauseTrailingWhitespaceOnOtherwiseEmptyLines
9593
, testCase "Ribbon width should be computed with `floor` instead of `round` (#157)"
9694
computeRibbonWidthWithFloor
9795
]
@@ -395,14 +393,6 @@ regressionUnboundedGroupedLineWithinAlign
395393
expected = SChar 'x' (SLine 0 (SChar 'y' SEmpty))
396394
in assertEqual "" expected sdoc
397395

398-
indentationShouldntCauseTrailingWhitespaceOnOtherwiseEmptyLines :: Assertion
399-
indentationShouldntCauseTrailingWhitespaceOnOtherwiseEmptyLines
400-
= let doc :: Doc ()
401-
doc = indent 1 ("x" <> hardline <> hardline <> "y" <> hardline)
402-
sdoc = layoutPretty (LayoutOptions Unbounded) doc
403-
expected = SChar ' ' (SChar 'x' (SLine 0 (SLine 1 (SChar 'y' (SLine 0 SEmpty)))))
404-
in assertEqual "" expected sdoc
405-
406396
computeRibbonWidthWithFloor :: Assertion
407397
computeRibbonWidthWithFloor
408398
= let doc :: Doc ()

0 commit comments

Comments
 (0)