on master help sign in
Recognize gaps between comment blocks
commitfaf3d86f14c8f343f2f4e77a7b30916c8e9dfbdb authorBasile Henry <bjm.henry@gmail.com> dateSat 29 Jun 2019, 13:31 (7 years ago) parent733e808
3 files changed+24−2
data/examples/other/comment-alignment-out.hs+9 data/examples/other/comment-alignment.hs+11 src/Ormolu/Printer/Comments.hs+4−2
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
1515import Control.Monad
1616import Data.Coerce (coerce)
1717import Data.Data (Data)
18−import Data.Maybe (isJust)
1918import Ormolu.CommentStream
2019import Ormolu.Printer.Internal
2120import Ormolu.Utils (isModule)
@@ -202,7 +201,10 @@ commentFollowsElt ref mnSpn meSpn mlastSpn (L l comment) =
202201 let startColumn = srcLocCol . realSrcSpanStart
203202 in abs (startColumn espn - startColumn l)
204203 >= 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
206208
207209-- | Output a 'Comment'. This is a low-level printing function.
208210