Stop hanging indent for IEThingWith
plus minor refactors/cleanups this is more in line with IndentPolicyLeft and imo also looks nicer in generalpull/124/head
parent
af7f9017b8
commit
20f9c009ee
|
@ -787,27 +787,33 @@ import Test ( -- comment
|
|||
)
|
||||
|
||||
#test long-bindings
|
||||
import Test ( longbindingNameThatoverflowsColum )
|
||||
import Test ( Long( List
|
||||
, Of
|
||||
, Things
|
||||
) )
|
||||
import Test ( longbindingNameThatoverflowsColum
|
||||
)
|
||||
import Test ( Long
|
||||
( List
|
||||
, Of
|
||||
, Things
|
||||
)
|
||||
)
|
||||
|
||||
#test things-with-with-comments
|
||||
import Test ( Thing( -- Comments
|
||||
)
|
||||
import Test ( Thing
|
||||
( -- Comments
|
||||
)
|
||||
)
|
||||
import Test ( Thing( Item
|
||||
-- and Comment
|
||||
)
|
||||
import Test ( Thing
|
||||
( Item
|
||||
-- and Comment
|
||||
)
|
||||
)
|
||||
import Test ( Thing( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
import Test ( Thing
|
||||
( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
)
|
||||
#test prefer-dense-empty-list
|
||||
import VeryLongModuleNameThatCouldEvenCauseAnEmptyBindingListToExpandIntoMultipleLine
|
||||
|
|
|
@ -792,27 +792,30 @@ import Test (Long(List, Of, Things))
|
|||
|
||||
#test things-with-with-comments
|
||||
import Test
|
||||
( Thing( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
( Thing
|
||||
( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
)
|
||||
import Test
|
||||
( Thing( Item
|
||||
-- and Comment
|
||||
)
|
||||
( Thing
|
||||
( Item
|
||||
-- and Comment
|
||||
)
|
||||
)
|
||||
import Test
|
||||
( Thing( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
( Thing
|
||||
( With
|
||||
-- Comments
|
||||
, and
|
||||
-- also
|
||||
, items
|
||||
-- !
|
||||
)
|
||||
)
|
||||
|
||||
#test prefer-dense-empty-list
|
||||
|
|
|
@ -47,10 +47,16 @@ layoutIE lie@(L _ ie) = docWrapNode lie $ case ie of
|
|||
IEThingWith _ _ ns _ -> do
|
||||
hasComments <- hasAnyCommentsBelow lie
|
||||
docAltFilter
|
||||
[(not hasComments, docSeq $ [ien, docLit $ Text.pack "("]
|
||||
[ ( not hasComments
|
||||
, docSeq
|
||||
$ [ien, docLit $ Text.pack "("]
|
||||
++ intersperse docCommaSep (map nameDoc ns)
|
||||
++ [docParenR])
|
||||
,(otherwise, docSeq [ien, layoutItems (splitFirstLast ns)])
|
||||
++ [docParenR]
|
||||
)
|
||||
, (otherwise
|
||||
, docAddBaseY BrIndentRegular
|
||||
$ docPar ien (layoutItems (splitFirstLast ns))
|
||||
)
|
||||
]
|
||||
where
|
||||
nameDoc = (docLit =<<) . lrdrNameToTextAnn . prepareName
|
||||
|
@ -113,21 +119,27 @@ layoutAnnAndSepLLIEs llies@(L _ lies) = do
|
|||
-- )
|
||||
layoutLLIEs :: Located [LIE RdrName] -> ToBriDocM BriDocNumbered
|
||||
layoutLLIEs llies = do
|
||||
ieDs <- layoutAnnAndSepLLIEs llies
|
||||
ieDs <- layoutAnnAndSepLLIEs llies
|
||||
hasComments <- hasAnyCommentsBelow llies
|
||||
case ieDs of
|
||||
[] -> docAltFilter
|
||||
[ (not hasComments, docLit $ Text.pack "()")
|
||||
, ( hasComments
|
||||
, docPar
|
||||
(docSeq [docParenLSep, docWrapNodeRest llies docEmpty])
|
||||
docParenR
|
||||
)
|
||||
]
|
||||
(ieDsH:ieDsT) ->
|
||||
docAltFilter
|
||||
[ (not hasComments, docSeq $ docLit (Text.pack "("):ieDs ++ [docParenR])
|
||||
, (otherwise, docPar (docSetBaseY $ docSeq [docParenLSep, ieDsH]) $
|
||||
docLines $ ieDsT
|
||||
++ [docParenR])
|
||||
]
|
||||
[ (not hasComments, docLit $ Text.pack "()")
|
||||
, ( hasComments
|
||||
, docPar (docSeq [docParenLSep, docWrapNodeRest llies docEmpty])
|
||||
docParenR
|
||||
)
|
||||
]
|
||||
(ieDsH:ieDsT) -> docAltFilter
|
||||
[ ( not hasComments
|
||||
, docSeq
|
||||
$ [docLit (Text.pack "(")]
|
||||
++ (docForceSingleline <$> ieDs)
|
||||
++ [docParenR]
|
||||
)
|
||||
, ( otherwise
|
||||
, docPar (docSetBaseY $ docSeq [docParenLSep, ieDsH])
|
||||
$ docLines
|
||||
$ ieDsT
|
||||
++ [docParenR]
|
||||
)
|
||||
]
|
||||
|
|
|
@ -95,9 +95,22 @@ layoutImport limportD@(L _ importD) = docWrapNode limportD $ case importD of
|
|||
docParenR
|
||||
else docSeq [hidDoc, docParenLSep, docSeparator, docParenR]
|
||||
-- ..[hiding].( b )
|
||||
[ieD] -> if hasComments
|
||||
then docPar (docSeq [hidDoc, docParenLSep, ieD]) docParenR
|
||||
else docSeq [hidDoc, docParenLSep, ieD, docSeparator, docParenR]
|
||||
[ieD] -> docAltFilter
|
||||
[ ( not hasComments
|
||||
, docSeq
|
||||
[ hidDoc
|
||||
, docParenLSep
|
||||
, docForceSingleline $ ieD
|
||||
, docSeparator
|
||||
, docParenR
|
||||
]
|
||||
)
|
||||
, ( otherwise
|
||||
, docPar
|
||||
(docSeq [hidDoc, docParenLSep, docNonBottomSpacing ieD])
|
||||
docParenR
|
||||
)
|
||||
]
|
||||
-- ..[hiding].( b
|
||||
-- , b'
|
||||
-- )
|
||||
|
@ -114,8 +127,7 @@ layoutImport limportD@(L _ importD) = docWrapNode limportD $ case importD of
|
|||
then
|
||||
let asDoc = maybe docEmpty makeAsDoc masT
|
||||
in docAlt
|
||||
[ docForceSingleline $
|
||||
docSeq [importHead, asDoc, docSetBaseY $ bindingsD]
|
||||
[ docForceSingleline $ docSeq [importHead, asDoc, bindingsD]
|
||||
, docAddBaseY BrIndentRegular $
|
||||
docPar (docSeq [importHead, asDoc]) bindingsD
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue