Fix comment/eof space handling (fixes #22)
parent
505ad99f35
commit
cbeab39b2d
|
@ -202,13 +202,17 @@ ppModule lmod@(L loc m@(HsModule _name _exports _imports decls _ _)) = do
|
||||||
ppmMoveToExactLoc l
|
ppmMoveToExactLoc l
|
||||||
mTell $ Text.Builder.fromString cmStr
|
mTell $ Text.Builder.fromString cmStr
|
||||||
(ExactPrint.Types.G AnnEofPos, (ExactPrint.Types.DP (eofX, eofY))) ->
|
(ExactPrint.Types.G AnnEofPos, (ExactPrint.Types.DP (eofX, eofY))) ->
|
||||||
let folder acc (kw, ExactPrint.Types.DP (x, _)) = case kw of
|
let
|
||||||
|
folder (acc, _) (kw, ExactPrint.Types.DP (x, y)) = case kw of
|
||||||
ExactPrint.Types.AnnComment cm
|
ExactPrint.Types.AnnComment cm
|
||||||
| GHC.RealSrcSpan span <- ExactPrint.Types.commentIdentifier cm
|
| GHC.RealSrcSpan span <- ExactPrint.Types.commentIdentifier cm
|
||||||
-> acc + x + GHC.srcSpanEndLine span - GHC.srcSpanStartLine span
|
-> ( acc + x + GHC.srcSpanEndLine span - GHC.srcSpanStartLine span
|
||||||
_ -> acc + x
|
, y + GHC.srcSpanEndCol span - GHC.srcSpanStartCol span
|
||||||
cmX = foldl' folder 0 finalComments
|
)
|
||||||
in ppmMoveToExactLoc $ ExactPrint.Types.DP (eofX - cmX, eofY)
|
_ -> (acc + x, y)
|
||||||
|
(cmX, cmY) = foldl' folder (0, 0) finalComments
|
||||||
|
in
|
||||||
|
ppmMoveToExactLoc $ ExactPrint.Types.DP (eofX - cmX, eofY - cmY)
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
withTransformedAnns :: SYB.Data ast => ast -> PPM () -> PPM ()
|
withTransformedAnns :: SYB.Data ast => ast -> PPM () -> PPM ()
|
||||||
|
|
Loading…
Reference in New Issue