Improve block-comment behaviour (newlines after or not)
parent
7c329d391b
commit
05270ecb45
|
@ -7,7 +7,7 @@ recorddot1 = a.b.c
|
||||||
#test getfield
|
#test getfield
|
||||||
{-# LANGUAGE OverloadedRecordDot #-}
|
{-# LANGUAGE OverloadedRecordDot #-}
|
||||||
recorddot2 =
|
recorddot2 =
|
||||||
{-before-}a.b.c{-after-}
|
{-before-} a.b.c {-after-}
|
||||||
|
|
||||||
#test projection
|
#test projection
|
||||||
{-# LANGUAGE OverloadedRecordDot #-}
|
{-# LANGUAGE OverloadedRecordDot #-}
|
||||||
|
|
|
@ -122,20 +122,38 @@ layoutWriteComment absolute isBlock dp commentLines s = do -- TODO92 we don't mo
|
||||||
GHC.SameLine c -> (0, c)
|
GHC.SameLine c -> (0, c)
|
||||||
GHC.DifferentLine l c -> (l, c)
|
GHC.DifferentLine l c -> (l, c)
|
||||||
state <- mGet
|
state <- mGet
|
||||||
mTell $ Text.Builder.fromString $ replicate y '\n' ++ replicate (if absolute && (y > 0) then x-1 else x) ' '
|
mTell $ Text.Builder.fromString $ replicate y '\n' ++ replicate
|
||||||
|
(if absolute && (y > 0) then x - 1 else x)
|
||||||
|
' '
|
||||||
mTell $ Text.Builder.fromText s
|
mTell $ Text.Builder.fromText s
|
||||||
traceLocal ("layoutMoveToCommentPos", y, x, commentLines, _lstate_plannedSpace state, lstate_baseY state)
|
traceLocal
|
||||||
|
( "layoutMoveToCommentPos"
|
||||||
|
, y
|
||||||
|
, x
|
||||||
|
, commentLines
|
||||||
|
, _lstate_plannedSpace state
|
||||||
|
, lstate_baseY state
|
||||||
|
)
|
||||||
mSet state
|
mSet state
|
||||||
{ _lstate_plannedSpace = if isBlock
|
{ _lstate_plannedSpace = if isBlock
|
||||||
then PlannedSameline 0
|
then case _lstate_plannedSpace state of
|
||||||
|
PlannedNone -> PlannedSameline 1
|
||||||
|
p@PlannedSameline{} -> p
|
||||||
|
PlannedNewline l ->
|
||||||
|
if l <= y then PlannedSameline 1 else PlannedNewline (l - y)
|
||||||
|
PlannedDelta l i ->
|
||||||
|
if l <= y then PlannedSameline 1 else PlannedDelta (l - y) i
|
||||||
else case _lstate_plannedSpace state of
|
else case _lstate_plannedSpace state of
|
||||||
PlannedNone -> PlannedDelta 1 (_lstate_curY state)
|
PlannedNone -> PlannedDelta 1 (_lstate_curY state)
|
||||||
PlannedSameline i -> PlannedDelta 1 (_lstate_curY state + i)
|
PlannedSameline i -> PlannedDelta 1 (_lstate_curY state + i)
|
||||||
p@PlannedNewline{} -> p
|
p@PlannedNewline{} -> p
|
||||||
p@PlannedDelta{} -> p
|
p@PlannedDelta{} -> p
|
||||||
, _lstate_commentNewlines =
|
, _lstate_commentNewlines = _lstate_commentNewlines state
|
||||||
_lstate_commentNewlines state + y + commentLines - 1
|
+ y
|
||||||
, _lstate_curY = if y == 0 then _lstate_curY state + x + Text.length s
|
+ commentLines
|
||||||
|
- 1
|
||||||
|
, _lstate_curY = if y == 0
|
||||||
|
then _lstate_curY state + x + Text.length s
|
||||||
else x + Text.length s
|
else x + Text.length s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue