Fix multiline-list indentation past comma level

ghc92
Lennart Spitzner 2023-06-20 11:50:58 +02:00
parent 278e0275f2
commit a6e187e962
4 changed files with 52 additions and 45 deletions

View File

@ -21,3 +21,10 @@ foo =
, 4 , 4
, 5 , 5
] ]
#test set-base-y for multiple line elements
foo =
[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
, bbbbbbbbbbbbbbbbbb
$ cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
]

View File

@ -215,13 +215,13 @@ showPackageDetailedInfo pkginfo =
(altText null "[ Not available from server ]") (altText null "[ Not available from server ]")
(dispTopVersions 9 (preferredVersions pkginfo)) (dispTopVersions 9 (preferredVersions pkginfo))
, entry , entry
"Versions installed" "Versions installed"
installedVersions installedVersions
(altText (altText
null null
(if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]")
) )
(dispTopVersions 4 (preferredVersions pkginfo)) (dispTopVersions 4 (preferredVersions pkginfo))
, entry "Homepage" homepage orNotSpecified text , entry "Homepage" homepage orNotSpecified text
, entry "Bug reports" bugReports orNotSpecified text , entry "Bug reports" bugReports orNotSpecified text
, entry "Description" description hideIfNull reflowParagraphs , entry "Description" description hideIfNull reflowParagraphs
@ -236,10 +236,10 @@ showPackageDetailedInfo pkginfo =
, entry "Documentation" haddockHtml showIfInstalled text , entry "Documentation" haddockHtml showIfInstalled text
, entry "Cached" haveTarball alwaysShow dispYesNo , entry "Cached" haveTarball alwaysShow dispYesNo
, if not (hasLib pkginfo) , if not (hasLib pkginfo)
then empty then empty
else else
text "Modules:" text "Modules:"
$+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo))
] ]
#test issue 7a #test issue 7a
@ -413,10 +413,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
(ColBindingLine alignmentToken) (ColBindingLine alignmentToken)
[ docSeq (patPartInline ++ [guardPart]) [ docSeq (patPartInline ++ [guardPart])
, docSeq , docSeq
[ appSep $ return binderDoc [ appSep $ return binderDoc
, docForceSingleline $ return body , docForceSingleline $ return body
, wherePart , wherePart
] ]
] ]
| not hasComments | not hasComments
, [(guards, body, _bodyRaw)] <- [clauseDocs] , [(guards, body, _bodyRaw)] <- [clauseDocs]
@ -436,7 +436,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
(ColBindingLine alignmentToken) (ColBindingLine alignmentToken)
[ docSeq (patPartInline ++ [guardPart]) [ docSeq (patPartInline ++ [guardPart])
, docSeq , docSeq
[appSep $ return binderDoc, docForceParSpacing $ return body] [appSep $ return binderDoc, docForceParSpacing $ return body]
] ]
] ]
++ wherePartMultiLine ++ wherePartMultiLine
@ -447,10 +447,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
++ -- two-line solution + where in next line(s) ++ -- two-line solution + where in next line(s)
[ docLines [ docLines
$ [ docForceSingleline $ docSeq $ [ docForceSingleline $ docSeq
(patPartInline ++ [guardPart, return binderDoc]) (patPartInline ++ [guardPart, return binderDoc])
, docEnsureIndent BrIndentRegular , docEnsureIndent BrIndentRegular
$ docForceSingleline $ docForceSingleline
$ return body $ return body
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]

View File

@ -1149,18 +1149,18 @@ showPackageDetailedInfo pkginfo =
$+$ something $+$ something
[ entry "Synopsis" synopsis hideIfNull reflowParagraphs [ entry "Synopsis" synopsis hideIfNull reflowParagraphs
, entry , entry
"Versions available" "Versions available"
sourceVersions sourceVersions
(altText null "[ Not available from server ]") (altText null "[ Not available from server ]")
(dispTopVersions 9 (preferredVersions pkginfo)) (dispTopVersions 9 (preferredVersions pkginfo))
, entry , entry
"Versions installed" "Versions installed"
installedVersions installedVersions
(altText (altText
null null
(if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]") (if hasLib pkginfo then "[ Not installed ]" else "[ Unknown ]")
) )
(dispTopVersions 4 (preferredVersions pkginfo)) (dispTopVersions 4 (preferredVersions pkginfo))
, entry "Homepage" homepage orNotSpecified text , entry "Homepage" homepage orNotSpecified text
, entry "Bug reports" bugReports orNotSpecified text , entry "Bug reports" bugReports orNotSpecified text
, entry "Description" description hideIfNull reflowParagraphs , entry "Description" description hideIfNull reflowParagraphs
@ -1175,10 +1175,10 @@ showPackageDetailedInfo pkginfo =
, entry "Documentation" haddockHtml showIfInstalled text , entry "Documentation" haddockHtml showIfInstalled text
, entry "Cached" haveTarball alwaysShow dispYesNo , entry "Cached" haveTarball alwaysShow dispYesNo
, if not (hasLib pkginfo) , if not (hasLib pkginfo)
then empty then empty
else else
text "Modules:" text "Modules:"
$+$ nest 4 (vcat (map disp . sort . modules $ pkginfo)) $+$ nest 4 (vcat (map disp . sort . modules $ pkginfo))
] ]
#test issue 7a #test issue 7a
@ -1339,10 +1339,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
(ColBindingLine alignmentToken) (ColBindingLine alignmentToken)
[ docSeq (patPartInline ++ [guardPart]) [ docSeq (patPartInline ++ [guardPart])
, docSeq , docSeq
[ appSep $ return binderDoc [ appSep $ return binderDoc
, docForceSingleline $ return body , docForceSingleline $ return body
, wherePart , wherePart
] ]
] ]
| not hasComments | not hasComments
, [(guards, body, _bodyRaw)] <- [clauseDocs] , [(guards, body, _bodyRaw)] <- [clauseDocs]
@ -1362,7 +1362,7 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
(ColBindingLine alignmentToken) (ColBindingLine alignmentToken)
[ docSeq (patPartInline ++ [guardPart]) [ docSeq (patPartInline ++ [guardPart])
, docSeq , docSeq
[appSep $ return binderDoc, docForceParSpacing $ return body] [appSep $ return binderDoc, docForceParSpacing $ return body]
] ]
] ]
++ wherePartMultiLine ++ wherePartMultiLine
@ -1373,10 +1373,10 @@ layoutPatternBindFinal alignmentToken binderDoc mPatDoc clauseDocs = do
++ -- two-line solution + where in next line(s) ++ -- two-line solution + where in next line(s)
[ docLines [ docLines
$ [ docForceSingleline $ docSeq $ [ docForceSingleline $ docSeq
(patPartInline ++ [guardPart, return binderDoc]) (patPartInline ++ [guardPart, return binderDoc])
, docEnsureIndent BrIndentRegular , docEnsureIndent BrIndentRegular
$ docForceSingleline $ docForceSingleline
$ return body $ return body
] ]
++ wherePartMultiLine ++ wherePartMultiLine
| [(guards, body, _bodyRaw)] <- [clauseDocs] | [(guards, body, _bodyRaw)] <- [clauseDocs]

View File

@ -736,15 +736,15 @@ layoutExpr lexpr@(L _ expr) = do
, docForceSingleline eN , docForceSingleline eN
, closeDoc] , closeDoc]
addAlternative addAlternative
$ let start = docCols ColList [appSep $ openDoc, e1] $ let start = docCols ColList [appSep $ openDoc, docSetBaseY e1]
linesM = ems <&> \(p, ast, d) -> linesM = ems <&> \(p, ast, d) ->
docCols docCols
ColList ColList
[ docHandleComms p docCommaSep [ docHandleComms p docCommaSep
, docFlushCommsPost True ast $ d , docSetBaseY $ docFlushCommsPost True ast $ d
] ]
lineN = docCols ColList lineN = docCols ColList
[docHandleComms finalCommaPos $ docCommaSep, eN] [docHandleComms finalCommaPos $ docCommaSep, docSetBaseY eN]
in docSetBaseY in docSetBaseY
$ docLines $ docLines
$ [start] $ [start]