mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-10-27 03:28:33 +03:00
Fix another case of non-idempotence with inline comments
This commit is contained in:
parent
76c4f523d7
commit
b0092e11a1
12
data/examples/other/inline-comment-1-out.hs
Normal file
12
data/examples/other/inline-comment-1-out.hs
Normal file
@ -0,0 +1,12 @@
|
||||
showPs env ((n, _, Let _ t v) : bs) =
|
||||
" " ++ show n ++ " : "
|
||||
++ showEnv env ({- normalise ctxt env -} t)
|
||||
++ " = "
|
||||
++ showEnv env ({- normalise ctxt env -} v)
|
||||
++ "\n"
|
||||
++ showPs env bs
|
||||
showPs env ((n, _, b) : bs) =
|
||||
" " ++ show n ++ " : "
|
||||
++ showEnv env ({- normalise ctxt env -} (binderTy b))
|
||||
++ "\n"
|
||||
++ showPs env bs
|
9
data/examples/other/inline-comment-1.hs
Normal file
9
data/examples/other/inline-comment-1.hs
Normal file
@ -0,0 +1,9 @@
|
||||
showPs env ((n, _, Let _ t v):bs)
|
||||
= " " ++ show n ++ " : " ++
|
||||
showEnv env ({- normalise ctxt env -} t) ++ " = " ++
|
||||
showEnv env ({- normalise ctxt env -} v) ++
|
||||
"\n" ++ showPs env bs
|
||||
showPs env ((n, _, b):bs)
|
||||
= " " ++ show n ++ " : " ++
|
||||
showEnv env ({- normalise ctxt env -} (binderTy b)) ++
|
||||
"\n" ++ showPs env bs
|
@ -4,12 +4,6 @@ Formatting is not idempotent:
|
||||
after: "t_impl ppo\n "
|
||||
Please, consider reporting the bug.
|
||||
|
||||
Formatting is not idempotent:
|
||||
src/Idris/Core/ProofState.hs<rendered>:163:20
|
||||
before: "++ showEnv env (\n "
|
||||
after: "++ showEnv\n "
|
||||
Please, consider reporting the bug.
|
||||
|
||||
Formatting is not idempotent:
|
||||
src/Idris/Core/TT.hs<rendered>:1963:13
|
||||
before: " text op <> pretty"
|
||||
|
@ -14,6 +14,7 @@ where
|
||||
|
||||
import Control.Monad
|
||||
import qualified Data.List.NonEmpty as NE
|
||||
import Data.Maybe (listToMaybe)
|
||||
import qualified Data.Text as T
|
||||
import Ormolu.Parser.CommentStream
|
||||
import Ormolu.Printer.Internal
|
||||
@ -66,9 +67,11 @@ spitPrecedingComment ref = do
|
||||
let p (L l _) = realSrcSpanEnd l <= realSrcSpanStart ref
|
||||
withPoppedComment p $ \l comment -> do
|
||||
lineSpans <- thisLineSpans
|
||||
let ls = srcLocLine . realSrcSpanEnd <$> lineSpans
|
||||
thisCommentLine = srcLocLine (realSrcSpanStart l)
|
||||
needsNewline = any (/= thisCommentLine) ls
|
||||
let thisCommentLine = srcLocLine (realSrcSpanStart l)
|
||||
needsNewline =
|
||||
case listToMaybe lineSpans of
|
||||
Nothing -> False
|
||||
Just spn -> srcLocLine (realSrcSpanEnd spn) /= thisCommentLine
|
||||
when (needsNewline || needsNewlineBefore l mlastMark) newline
|
||||
spitCommentNow l comment
|
||||
if theSameLinePre l ref
|
||||
|
Loading…
Reference in New Issue
Block a user