mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-10-27 03:28:33 +03:00
Make sure no comments are swallowed at the end
This commit is contained in:
parent
ca1a2e9e5c
commit
93271b2551
3
data/examples/other/following-comment-last-0-out.hs
Normal file
3
data/examples/other/following-comment-last-0-out.hs
Normal file
@ -0,0 +1,3 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
-- ^ ...with two docstrings.
|
3
data/examples/other/following-comment-last-0.hs
Normal file
3
data/examples/other/following-comment-last-0.hs
Normal file
@ -0,0 +1,3 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
-- ^ ...with two docstrings.
|
6
data/examples/other/following-comment-last-1-out.hs
Normal file
6
data/examples/other/following-comment-last-1-out.hs
Normal file
@ -0,0 +1,6 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
deriving (Show)
|
||||
-- ^ ...with two docstrings.
|
||||
|
||||
-- more
|
6
data/examples/other/following-comment-last-1.hs
Normal file
6
data/examples/other/following-comment-last-1.hs
Normal file
@ -0,0 +1,6 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
deriving (Show)
|
||||
-- ^ ...with two docstrings.
|
||||
|
||||
-- more
|
7
data/examples/other/following-comment-last-2-out.hs
Normal file
7
data/examples/other/following-comment-last-2-out.hs
Normal file
@ -0,0 +1,7 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
deriving (Show)
|
||||
-- ^ ...with two docstrings.
|
||||
|
||||
-- more
|
||||
data B
|
8
data/examples/other/following-comment-last-2.hs
Normal file
8
data/examples/other/following-comment-last-2.hs
Normal file
@ -0,0 +1,8 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
deriving (Show)
|
||||
-- ^ ...with two docstrings.
|
||||
|
||||
-- more
|
||||
|
||||
data B
|
4
data/examples/other/following-comment-last-3-out.hs
Normal file
4
data/examples/other/following-comment-last-3-out.hs
Normal file
@ -0,0 +1,4 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
-- ^ ...with two docstrings.
|
||||
-- even on second line
|
4
data/examples/other/following-comment-last-3.hs
Normal file
4
data/examples/other/following-comment-last-3.hs
Normal file
@ -0,0 +1,4 @@
|
||||
-- | Another datatype...
|
||||
data D'
|
||||
-- ^ ...with two docstrings.
|
||||
-- even on second line
|
@ -15,6 +15,7 @@ import GHC
|
||||
import Ormolu.Imports
|
||||
import Ormolu.Printer.Combinators
|
||||
import Ormolu.Printer.Comments
|
||||
import Ormolu.Printer.Internal (isNewlineModified)
|
||||
import Ormolu.Printer.Meat.Common
|
||||
import Ormolu.Printer.Meat.Declaration
|
||||
import Ormolu.Printer.Meat.Declaration.Warning
|
||||
@ -54,7 +55,13 @@ p_hsModule exts (L moduleSpan HsModule {..}) = do
|
||||
forM_ (sortImports hsmodImports) (located' p_hsmodImport)
|
||||
when (hasImports && hasDecls) newline
|
||||
p_hsDecls Free hsmodDecls
|
||||
when hasDecls newline
|
||||
trailingComments <- hasMoreComments
|
||||
when hasDecls $ do
|
||||
newlineModified <- isNewlineModified
|
||||
newline
|
||||
-- In this case we need to insert a newline between the comments
|
||||
-- output as a side effect of the previous newline and trailing
|
||||
-- comments to prevent them from merging.
|
||||
when (newlineModified && trailingComments) newline
|
||||
when (trailingComments && hasModuleHeader) newline
|
||||
spitRemainingComments
|
||||
|
Loading…
Reference in New Issue
Block a user