File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
src/Data/Text/Prettyprint/Doc Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -1490,9 +1490,7 @@ removeTrailingWhitespace = go (RecordedWhitespace [] 0)
14901490 -- release only the necessary ones.
14911491 go (RecordedWhitespace withheldLines withheldSpaces) = \ sds -> case sds of
14921492 SFail -> SFail
1493- SEmpty -> if null withheldLines
1494- then SEmpty
1495- else SLine 0 SEmpty -- do not remove the last newline, Unix-style
1493+ SEmpty -> foldr (\ _i sds' -> SLine 0 sds') SEmpty withheldLines
14961494 SChar c rest
14971495 | c == ' ' -> go (RecordedWhitespace withheldLines (withheldSpaces+ 1 )) rest
14981496 | otherwise -> commitSpaces
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ tests = testGroup "Tests"
7171 , testCase " Keep single trailing newline"
7272 removeTrailingWhitespaceKeepTrailingNewline
7373 , testCase " Reduce to single trailing newline"
74- removeTrailingWhitespaceReduceToSingleTrailingNewline
74+ removeTrailingWhitespaceInTrailingNewlines
7575 ]
7676 ]
7777 ]
@@ -262,9 +262,9 @@ removeTrailingWhitespaceKeepLonelyTrailingNewline
262262 sdoc = SChar ' x' (SLine 0 SEmpty )
263263 in assertEqual " " sdoc (removeTrailingWhitespace sdoc)
264264
265- removeTrailingWhitespaceReduceToSingleTrailingNewline :: Assertion
266- removeTrailingWhitespaceReduceToSingleTrailingNewline
265+ removeTrailingWhitespaceInTrailingNewlines :: Assertion
266+ removeTrailingWhitespaceInTrailingNewlines
267267 = let sdoc :: SimpleDocStream ()
268268 sdoc = SChar ' x' (SLine 2 (SLine 2 SEmpty ))
269- sdoc' = SChar ' x' (SLine 0 SEmpty )
269+ sdoc' = SChar ' x' (SLine 0 ( SLine 0 SEmpty ) )
270270 in assertEqual " " sdoc' (removeTrailingWhitespace sdoc)
You can’t perform that action at this time.
0 commit comments