Fix issue with indentation after block-comments
parent
47bcdb045b
commit
860c8771ae
|
@ -145,7 +145,7 @@ doop =
|
||||||
#expected
|
#expected
|
||||||
doop =
|
doop =
|
||||||
some long invocation == loooooooooongman + (third nested expression) - 4
|
some long invocation == loooooooooongman + (third nested expression) - 4
|
||||||
&& {- meow -} 5 - 6 > 7 `mod` loooooooooongwoman
|
&& {- meow -} 5 - 6 > 7 `mod` loooooooooongwoman
|
||||||
|| ill just invoke a function with these args
|
|| ill just invoke a function with these args
|
||||||
|| foo
|
|| foo
|
||||||
&& dooasdoiaosdoi ** oaisdoioasido
|
&& dooasdoiaosdoi ** oaisdoioasido
|
||||||
|
@ -165,7 +165,7 @@ doop =
|
||||||
-- brittany { lconfig_fixityBasedAddAlignParens: True }
|
-- brittany { lconfig_fixityBasedAddAlignParens: True }
|
||||||
doop =
|
doop =
|
||||||
( ( some long invocation == loooooooooongman + (third nested expression) - 4
|
( ( some long invocation == loooooooooongman + (third nested expression) - 4
|
||||||
&& {- meow -} 5 - 6 > 7 `mod` loooooooooongwoman
|
&& {- meow -} 5 - 6 > 7 `mod` loooooooooongwoman
|
||||||
)
|
)
|
||||||
|| ill just invoke a function with these args
|
|| ill just invoke a function with these args
|
||||||
|| ( foo
|
|| ( foo
|
||||||
|
|
|
@ -57,9 +57,9 @@ test = Proxy @'[{- comment -} 'True ]
|
||||||
#test with-comment-4
|
#test with-comment-4
|
||||||
test
|
test
|
||||||
:: Proxy '[{- comment -}
|
:: Proxy '[{- comment -}
|
||||||
'True ]
|
'True ]
|
||||||
test = Proxy @'[{- comment -}
|
test = Proxy @'[{- comment -}
|
||||||
'True ]
|
'True ]
|
||||||
|
|
||||||
#test with-comment-5
|
#test with-comment-5
|
||||||
test
|
test
|
||||||
|
@ -69,9 +69,9 @@ test = Proxy @'[{- comment -} True]
|
||||||
#test with-comment-6
|
#test with-comment-6
|
||||||
test
|
test
|
||||||
:: Proxy '[{- comment -}
|
:: Proxy '[{- comment -}
|
||||||
True]
|
True]
|
||||||
test = Proxy @'[{- comment -}
|
test = Proxy @'[{- comment -}
|
||||||
True]
|
True]
|
||||||
|
|
||||||
#test explicit-list-type non-promoted
|
#test explicit-list-type non-promoted
|
||||||
type Foo = '[Bool, Bool, Bool]
|
type Foo = '[Bool, Bool, Bool]
|
||||||
|
|
|
@ -985,3 +985,11 @@ instance BMGuwigoc POtfuggj where
|
||||||
|
|
||||||
#test bang-type
|
#test bang-type
|
||||||
data LabeledBool = LabeledBool !Int !Bool
|
data LabeledBool = LabeledBool !Int !Bool
|
||||||
|
|
||||||
|
#test block-comment after let
|
||||||
|
func = do
|
||||||
|
let cipInuihz = Vuozczdm.yhEfun tuhiuRasohy
|
||||||
|
let {- CAZEB mecwbd "Caa ||" -}
|
||||||
|
doeeRbaviceQzymin a b = olivhuwqbaq
|
||||||
|
iqnz biwomeJhhujy _ _ | biwomeJhhujy < volpoqAsizmHdwpl = pure 0
|
||||||
|
pure True
|
||||||
|
|
|
@ -275,21 +275,53 @@ layoutBriDocM = \case
|
||||||
layoutBriDocM bd
|
layoutBriDocM bd
|
||||||
BDFlushCommentsPrior loc bd -> do
|
BDFlushCommentsPrior loc bd -> do
|
||||||
comms <- takeBefore loc
|
comms <- takeBefore loc
|
||||||
|
startCurY <- mGet <&> _lstate_curY
|
||||||
printComments comms
|
printComments comms
|
||||||
mModify (\s -> s + CommentCounter (length comms))
|
mModify (\s -> s + CommentCounter (length comms))
|
||||||
mModify $ \s -> s
|
mModify $ \s -> s
|
||||||
{ _lstate_markerForDelta = Nothing
|
{ _lstate_markerForDelta = Nothing
|
||||||
, _lstate_plannedSpace = case _lstate_markerForDelta s of
|
, _lstate_plannedSpace =
|
||||||
|
case _lstate_markerForDelta s of
|
||||||
Nothing -> _lstate_plannedSpace s
|
Nothing -> _lstate_plannedSpace s
|
||||||
Just m ->
|
Just m ->
|
||||||
let p1 = (srcLocLine m, srcLocCol m)
|
let p1 = (srcLocLine m, srcLocCol m)
|
||||||
p2 = (srcLocLine loc, srcLocCol loc)
|
p2 = (srcLocLine loc, srcLocCol loc)
|
||||||
-- traceShow (m, ExactPrint.pos2delta p1 p2) $ pure ()
|
in -- trace ("_lstate_plannedSpace = " ++ show (_lstate_plannedSpace s)
|
||||||
in case ExactPrint.pos2delta p1 p2 of
|
-- ++ ", _lstate_markerForDelta = " ++ show (_lstate_markerForDelta s)
|
||||||
SameLine{} -> _lstate_plannedSpace s
|
-- ++ ", _lstate_curY = " ++ show (_lstate_curY s)
|
||||||
|
-- ++ ", p1 = " ++ show p1
|
||||||
|
-- ++ ", p2 = " ++ show p2
|
||||||
|
-- ++ ", startCurY = " ++ show startCurY
|
||||||
|
-- -- ++ ", delta = " ++ show (ExactPrint.pos2delta p1 p2)
|
||||||
|
-- ) $
|
||||||
|
case ExactPrint.pos2delta p1 p2 of
|
||||||
|
SameLine iDelta -> case _lstate_plannedSpace s of
|
||||||
|
-- There is a delta after a marker. That should only happen
|
||||||
|
-- after a block-comment. And the marker-delta is SameLine,
|
||||||
|
-- so if layout doesn't force a newline we respect the marker
|
||||||
|
-- delta (i.e. respect whitespace immediately after a block
|
||||||
|
-- comment) or we just use the plan.
|
||||||
|
PlannedNone -> PlannedSameline iDelta
|
||||||
|
PlannedSameline i -> PlannedSameline (max (iDelta - 0) i)
|
||||||
|
p@PlannedNewline{} -> p
|
||||||
|
p@PlannedDelta{} -> p
|
||||||
DifferentLine n _ -> case _lstate_plannedSpace s of
|
DifferentLine n _ -> case _lstate_plannedSpace s of
|
||||||
PlannedNone -> PlannedNone
|
-- Marker with DifferentLine delta means that we want to
|
||||||
PlannedSameline i -> PlannedDelta n (_lstate_curY s + i)
|
-- reproduce the newlines that were present in the input.
|
||||||
|
-- These will be emptylines in cases where it makes sense to
|
||||||
|
-- reproduce them, e.g. between statements in a do-block.
|
||||||
|
PlannedNone -> PlannedDelta n startCurY
|
||||||
|
-- ^^^^^^^^^
|
||||||
|
--
|
||||||
|
-- after a block-comment, _lstate_curY
|
||||||
|
-- matches the end of the comment.
|
||||||
|
-- But to not break layout we need to
|
||||||
|
-- restore the original.
|
||||||
|
-- E.g. consider > let {-comm-}
|
||||||
|
-- > x = 13
|
||||||
|
--
|
||||||
|
-- vvvvvvvvvvvvvvv
|
||||||
|
PlannedSameline i -> PlannedDelta n (startCurY + i)
|
||||||
PlannedNewline{} -> PlannedNewline n
|
PlannedNewline{} -> PlannedNewline n
|
||||||
PlannedDelta _ i -> PlannedDelta n i
|
PlannedDelta _ i -> PlannedDelta n i
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ layoutWriteComment absolute isBlock dp commentLines s = do -- TODO92 we don't mo
|
||||||
mSet state
|
mSet state
|
||||||
{ _lstate_plannedSpace = if isBlock
|
{ _lstate_plannedSpace = if isBlock
|
||||||
then case _lstate_plannedSpace state of
|
then case _lstate_plannedSpace state of
|
||||||
PlannedNone -> PlannedSameline 1
|
p@PlannedNone -> p
|
||||||
p@PlannedSameline{} -> p
|
p@PlannedSameline{} -> p
|
||||||
PlannedNewline l ->
|
PlannedNewline l ->
|
||||||
if l <= y then PlannedSameline 1 else PlannedNewline (l - y)
|
if l <= y then PlannedSameline 1 else PlannedNewline (l - y)
|
||||||
|
|
Loading…
Reference in New Issue