Refactor WriteBriDoc FlushCommentsPrior code slightly
parent
d2a48ba559
commit
556bc896a6
|
@ -277,24 +277,22 @@ layoutBriDocM = \case
|
||||||
comms <- takeBefore loc
|
comms <- takeBefore loc
|
||||||
printComments comms
|
printComments comms
|
||||||
mModify (\s -> s + CommentCounter (length comms))
|
mModify (\s -> s + CommentCounter (length comms))
|
||||||
do
|
mModify $ \s -> s
|
||||||
state <- mGet
|
{ _lstate_markerForDelta = Nothing
|
||||||
mModify $ \s -> s { _lstate_markerForDelta = Nothing }
|
, _lstate_plannedSpace = case _lstate_markerForDelta s of
|
||||||
case _lstate_markerForDelta state of
|
Nothing -> _lstate_plannedSpace s
|
||||||
Just m -> do
|
Just m ->
|
||||||
let p1 = (srcLocLine m, srcLocCol m)
|
let p1 = (srcLocLine m, srcLocCol m)
|
||||||
let p2 = (srcLocLine loc, srcLocCol loc)
|
p2 = (srcLocLine loc, srcLocCol loc)
|
||||||
let newlinePlanned = case _lstate_plannedSpace state of
|
-- traceShow (m, ExactPrint.pos2delta p1 p2) $ pure ()
|
||||||
PlannedNone -> False
|
in case ExactPrint.pos2delta p1 p2 of
|
||||||
PlannedSameline{} -> False
|
SameLine{} -> _lstate_plannedSpace s
|
||||||
PlannedNewline{} -> True
|
DifferentLine n _ -> case _lstate_plannedSpace s of
|
||||||
PlannedDelta{} -> True
|
PlannedNone -> PlannedNone
|
||||||
-- traceShow (m, ExactPrint.pos2delta p1 p2) $ pure ()
|
PlannedSameline i -> PlannedSameline i
|
||||||
case ExactPrint.pos2delta p1 p2 of
|
PlannedNewline{} -> PlannedNewline n
|
||||||
SameLine{} -> pure ()
|
PlannedDelta{} -> PlannedNewline n
|
||||||
DifferentLine n _ | newlinePlanned -> layoutWriteNewlines n
|
}
|
||||||
| otherwise -> pure ()
|
|
||||||
_ -> pure ()
|
|
||||||
layoutBriDocM bd
|
layoutBriDocM bd
|
||||||
BDFlushCommentsPost loc shouldMark bd -> do
|
BDFlushCommentsPost loc shouldMark bd -> do
|
||||||
layoutBriDocM bd
|
layoutBriDocM bd
|
||||||
|
|
Loading…
Reference in New Issue