on master help sign in
Recognize gaps between comment blocks
faf3d86Basile Henry
data/examples/other/comment-alignment-out.hsnew file+9
@@ -0,0 +1,9 @@
1+class Foo a where
2+
3+ -- | Foo.
4+ foo
5+ :: Int
6+ -> a -- ^ Something
7+
8+ -- | Bar.
9+ bar :: a
data/examples/other/comment-alignment.hsnew file+11
@@ -0,0 +1,11 @@
1+class Foo a where
2+
3+ -- | Foo.
4+
5+ foo
6+ :: Int
7+ -> a -- ^ Something
8+
9+ -- | Bar.
10+
11+ bar :: a
src/Ormolu/Printer/Comments.hs+4−2
@@ -15,7 +15,6 @@ where
15import Control.Monad
15import Control.Monad
16import Data.Coerce (coerce)
16import Data.Coerce (coerce)
17import Data.Data (Data)
17import Data.Data (Data)
18−import Data.Maybe (isJust)
19import Ormolu.CommentStream
18import Ormolu.CommentStream
20import Ormolu.Printer.Internal
19import Ormolu.Printer.Internal
21import Ormolu.Utils (isModule)
20import Ormolu.Utils (isModule)
@@ -202,7 +201,10 @@ commentFollowsElt ref mnSpn meSpn mlastSpn (L l comment) =
202 let startColumn = srcLocCol . realSrcSpanStart
201 let startColumn = srcLocCol . realSrcSpanStart
203 in abs (startColumn espn - startColumn l)
202 in abs (startColumn espn - startColumn l)
204 >= abs (startColumn ref - startColumn l)
203 >= abs (startColumn ref - startColumn l)
205− continuation = isJust mlastSpn
204+ continuation =
205+ case mlastSpn of
206+ Nothing -> False
207+ Just spn -> srcSpanEndLine spn + 1 == srcSpanStartLine l
206
208
207-- | Output a 'Comment'. This is a low-level printing function.
209-- | Output a 'Comment'. This is a low-level printing function.
208
210