Fix comment insertion error introduced in 91b9a240

pull/51/head
Lennart Spitzner 2017-08-10 13:09:39 +02:00
parent 08e94f0e74
commit 655074d1c0
3 changed files with 27 additions and 24 deletions

View File

@ -1006,6 +1006,17 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
, let guardPart = singleLineGuardsDoc guards
]
#test comment-testcase-17
{-# LANGUAGE MultiWayIf #-}
func = do
let foo = if
| Constuctoooooooooooooooooooooooooooooooooooor `elem` artics -- TODO
-> max
(defLen - 0.2) -- TODO
(defLen * 0.8)
| otherwise -> max (defLen - 0.05) (defLen * 0.95) -- TODO
return True
###############################################################################
###############################################################################

View File

@ -167,7 +167,6 @@ layoutBriDocM = \case
Just [] -> when allowMTEL $ moveToExactAnn annKey
Just priors -> do
-- layoutResetSepSpace
when (not $ null priors) $ layoutSetCommentCol
priors
`forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
do
@ -209,7 +208,6 @@ layoutBriDocM = \case
case mComments of
Nothing -> pure ()
Just comments -> do
layoutSetCommentCol
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
do
-- evil hack for CPP:
@ -241,7 +239,6 @@ layoutBriDocM = \case
case mComments of
Nothing -> pure ()
Just comments -> do
layoutSetCommentCol
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
do
-- evil hack for CPP:

View File

@ -184,28 +184,23 @@ layoutMoveToCommentPos
layoutMoveToCommentPos y x = do
traceLocal ("layoutMoveToCommentPos", y, x)
state <- mGet
if Data.Maybe.isJust (_lstate_commentCol state)
then do
mSet state
{ _lstate_curYOrAddNewline = case _lstate_curYOrAddNewline state of
Left i -> if y == 0 then Left i else Right y
Right{} -> Right y
, _lstate_addSepSpace = Just $ case _lstate_curYOrAddNewline state of
, _lstate_addSepSpace = if Data.Maybe.isJust (_lstate_commentCol state)
then Just $ case _lstate_curYOrAddNewline state of
Left{} -> if y == 0 then x else _lstate_indLevelLinger state + x
Right{} -> _lstate_indLevelLinger state + x
}
else do
mSet state
{ _lstate_curYOrAddNewline = case _lstate_curYOrAddNewline state of
Left i -> if y == 0 then Left i else Right y
Right{} -> Right y
, _lstate_addSepSpace = Just
$ if y == 0 then x else _lstate_indLevelLinger state + x
, _lstate_commentCol = Just $ case _lstate_curYOrAddNewline state of
else Just $ if y == 0 then x else _lstate_indLevelLinger state + x
, _lstate_commentCol = Just $ case _lstate_commentCol state of
Just existing -> existing
Nothing -> case _lstate_curYOrAddNewline state of
Left i -> i + fromMaybe 0 (_lstate_addSepSpace state)
Right{} -> lstate_baseY state
}
-- | does _not_ add spaces to again reach the current base column.
layoutWriteNewline
:: ( MonadMultiWriter Text.Builder.Builder m