Fix comment insertion error introduced in 91b9a240
parent
08e94f0e74
commit
655074d1c0
|
@ -1006,6 +1006,17 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
|
||||||
, let guardPart = singleLineGuardsDoc guards
|
, 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
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -167,7 +167,6 @@ layoutBriDocM = \case
|
||||||
Just [] -> when allowMTEL $ moveToExactAnn annKey
|
Just [] -> when allowMTEL $ moveToExactAnn annKey
|
||||||
Just priors -> do
|
Just priors -> do
|
||||||
-- layoutResetSepSpace
|
-- layoutResetSepSpace
|
||||||
when (not $ null priors) $ layoutSetCommentCol
|
|
||||||
priors
|
priors
|
||||||
`forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
`forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
||||||
do
|
do
|
||||||
|
@ -209,7 +208,6 @@ layoutBriDocM = \case
|
||||||
case mComments of
|
case mComments of
|
||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
Just comments -> do
|
Just comments -> do
|
||||||
layoutSetCommentCol
|
|
||||||
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
||||||
do
|
do
|
||||||
-- evil hack for CPP:
|
-- evil hack for CPP:
|
||||||
|
@ -241,7 +239,6 @@ layoutBriDocM = \case
|
||||||
case mComments of
|
case mComments of
|
||||||
Nothing -> pure ()
|
Nothing -> pure ()
|
||||||
Just comments -> do
|
Just comments -> do
|
||||||
layoutSetCommentCol
|
|
||||||
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
comments `forM_` \(ExactPrint.Types.Comment comment _ _, ExactPrint.Types.DP (y, x)) ->
|
||||||
do
|
do
|
||||||
-- evil hack for CPP:
|
-- evil hack for CPP:
|
||||||
|
|
|
@ -184,27 +184,22 @@ layoutMoveToCommentPos
|
||||||
layoutMoveToCommentPos y x = do
|
layoutMoveToCommentPos y x = do
|
||||||
traceLocal ("layoutMoveToCommentPos", y, x)
|
traceLocal ("layoutMoveToCommentPos", y, x)
|
||||||
state <- mGet
|
state <- mGet
|
||||||
if Data.Maybe.isJust (_lstate_commentCol state)
|
mSet state
|
||||||
then do
|
{ _lstate_curYOrAddNewline = case _lstate_curYOrAddNewline state of
|
||||||
mSet state
|
Left i -> if y == 0 then Left i else Right y
|
||||||
{ _lstate_curYOrAddNewline = case _lstate_curYOrAddNewline state of
|
Right{} -> Right y
|
||||||
Left i -> if y == 0 then Left i else Right y
|
, _lstate_addSepSpace = if Data.Maybe.isJust (_lstate_commentCol state)
|
||||||
Right{} -> Right y
|
then Just $ case _lstate_curYOrAddNewline state of
|
||||||
, _lstate_addSepSpace = Just $ case _lstate_curYOrAddNewline state of
|
Left{} -> if y == 0 then x else _lstate_indLevelLinger state + x
|
||||||
Left{} -> if y == 0 then x else _lstate_indLevelLinger state + x
|
Right{} -> _lstate_indLevelLinger state + x
|
||||||
Right{} -> _lstate_indLevelLinger state + x
|
else Just $ if y == 0 then x else _lstate_indLevelLinger state + x
|
||||||
}
|
, _lstate_commentCol = Just $ case _lstate_commentCol state of
|
||||||
else do
|
Just existing -> existing
|
||||||
mSet state
|
Nothing -> case _lstate_curYOrAddNewline state of
|
||||||
{ _lstate_curYOrAddNewline = case _lstate_curYOrAddNewline state of
|
Left i -> i + fromMaybe 0 (_lstate_addSepSpace state)
|
||||||
Left i -> if y == 0 then Left i else Right y
|
Right{} -> lstate_baseY state
|
||||||
Right{} -> Right y
|
}
|
||||||
, _lstate_addSepSpace = Just
|
|
||||||
$ if y == 0 then x else _lstate_indLevelLinger state + x
|
|
||||||
, _lstate_commentCol = Just $ 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.
|
-- | does _not_ add spaces to again reach the current base column.
|
||||||
layoutWriteNewline
|
layoutWriteNewline
|
||||||
|
|
Loading…
Reference in New Issue