Fix let-in-expr non-idempotent comment placement

ghc92
Lennart Spitzner 2023-08-28 21:31:25 +02:00
parent 15fc8ec332
commit 7d84705e7a
3 changed files with 25 additions and 8 deletions

View File

@ -1113,3 +1113,16 @@ func = do
func arg = abc ++ def ++ case arg of
False -> ghi
True -> jkl
#test non-idempotent comment position with let-in-where
otherFunc very long patterrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrn
= let
localfunc a b c = a <> b <> c
someThing = fromList [abc, def, ghi]
in -- abc
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ ccccccc
where
ccccccc = "abc"
ddddd = True

View File

@ -553,10 +553,11 @@ layoutExpr lexpr@(L _ expr) = do
]
, docAlt
[ docSeq
[ appSep $ wrapIn $ docLit $ Text.pack $ ifIndentFreeElse
"in "
"in"
, ifIndentFreeElse docSetBaseAndIndent
[ appSep $ wrapIn $ docLit $ Text.pack "in"
, ifIndentFreeElse ( docSetBaseAndIndent
. docEnsureIndent (BrIndentSpecial 1)
. docSetBaseAndIndent
)
docForceSingleline
expDoc1
]
@ -585,7 +586,8 @@ layoutExpr lexpr@(L _ expr) = do
$ docSetBaseAndIndent $ docLines $ pure <$> bindDocs
)
, docSeq
[ wrapIn $ docLit $ Text.pack "in "
[ wrapIn $ docLit $ Text.pack "in"
, docSeparator
, docAddBaseY BrIndentRegular $ docForceParSpacing expDoc1
]
]
@ -598,8 +600,10 @@ layoutExpr lexpr@(L _ expr) = do
, wrapBinds $ docSetBaseAndIndent $ docLines $ pure <$> bindDocs
]
, docSeq
[ appSep $ wrapIn $ docLit $ Text.pack "in "
, docSetBaseY expDoc1
[ appSep $ wrapIn $ docLit $ Text.pack "in"
, docSetBaseY
$ docEnsureIndent (BrIndentSpecial 1)
$ docSetBaseY expDoc1
]
]
addAlternative $ docLines

View File

@ -143,7 +143,7 @@ layoutWriteComment absolute isBlock dp commentLines s = do
' '
mTell $ Text.Builder.fromText s
traceLocal
( "layoutMoveToCommentPos"
( "layoutWriteComment"
, y
, x
, commentLines