Fix the bug when comments in different styles get glued together

This commit is contained in:
Mark Karpov 2020-06-23 21:46:05 +02:00
parent c97ba55762
commit e29dd2b1c7
5 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,8 @@
## Ormolu 0.1.2.0
* Fixed the bug when comments in different styles got glued together after
formatting. [Issue 589](https://github.com/tweag/ormolu/issues/589).
## Ormolu 0.1.1.0
* Imports in a import lists are now normalized: duplicate imports are

View File

@ -0,0 +1,7 @@
module Main (main) where
-- | Foo.
-- Bar
main :: IO ()
main = return ()

View File

@ -0,0 +1,6 @@
module Main (main) where
{- | Foo. -}
-- Bar
main :: IO ()
main = return ()

View File

@ -2,10 +2,6 @@ The GHC parser (in Haddock mode) failed:
src/Idris/Parser.hs:1052:1
parse error on input `@'
AST of input and AST of formatted code differ.
at src/Idris/Parser/Data.hs:281:1-29
Please, consider reporting the bug.
The GHC parser (in Haddock mode) failed:
src/Idris/Parser/Expr.hs:75:1
parse error on input `@'

View File

@ -154,6 +154,7 @@ needsNewlineBefore ::
-- | Last printed comment span
Maybe SpanMark ->
Bool
needsNewlineBefore _ (Just (HaddockSpan _ _)) = True
needsNewlineBefore l mlastMark =
case spanMarkSpan <$> mlastMark of
Nothing -> False
@ -238,8 +239,7 @@ commentFollowsElt ref mnSpn meSpn mlastMark (L l comment) =
-- lexemes in front of it and goes right after the previous comment.
not (hasAtomsBefore comment)
&& ( case mlastMark of
Just (HaddockSpan _ spn) ->
srcSpanEndLine spn + 1 == srcSpanStartLine l
Just (HaddockSpan _ _) -> False
Just (CommentSpan spn) ->
srcSpanEndLine spn + 1 == srcSpanStartLine l
_ -> False