mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-09-12 00:37:30 +03:00
Fix the bug when comments in different styles get glued together
This commit is contained in:
parent
c97ba55762
commit
e29dd2b1c7
@ -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
|
||||
|
7
data/examples/other/comment-glued-together-out.hs
Normal file
7
data/examples/other/comment-glued-together-out.hs
Normal file
@ -0,0 +1,7 @@
|
||||
module Main (main) where
|
||||
|
||||
-- | Foo.
|
||||
|
||||
-- Bar
|
||||
main :: IO ()
|
||||
main = return ()
|
6
data/examples/other/comment-glued-together.hs
Normal file
6
data/examples/other/comment-glued-together.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module Main (main) where
|
||||
|
||||
{- | Foo. -}
|
||||
-- Bar
|
||||
main :: IO ()
|
||||
main = return ()
|
@ -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 `@'
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user