Stop hanging indent for IEThingWith

plus minor refactors/cleanups

this is more in line with IndentPolicyLeft and imo also looks
nicer in general
pull/124/head
Lennart Spitzner 2018-03-11 22:42:47 +01:00
parent af7f9017b8
commit 20f9c009ee
4 changed files with 90 additions and 57 deletions

View File

@ -787,21 +787,27 @@ import Test ( -- comment
)
#test long-bindings
import Test ( longbindingNameThatoverflowsColum )
import Test ( Long( List
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
import Test ( Thing
( Item
-- and Comment
)
)
import Test ( Thing( With
import Test ( Thing
( With
-- Comments
, and
-- also

View File

@ -792,7 +792,8 @@ import Test (Long(List, Of, Things))
#test things-with-with-comments
import Test
( Thing( With
( Thing
( With
-- Comments
, and
-- also
@ -801,12 +802,14 @@ import Test
)
)
import Test
( Thing( Item
( Thing
( Item
-- and Comment
)
)
import Test
( Thing( With
( Thing
( With
-- Comments
, and
-- also

View File

@ -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
@ -119,15 +125,21 @@ layoutLLIEs llies = do
[] -> docAltFilter
[ (not hasComments, docLit $ Text.pack "()")
, ( hasComments
, docPar
(docSeq [docParenLSep, docWrapNodeRest llies docEmpty])
, 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])
(ieDsH:ieDsT) -> docAltFilter
[ ( not hasComments
, docSeq
$ [docLit (Text.pack "(")]
++ (docForceSingleline <$> ieDs)
++ [docParenR]
)
, ( otherwise
, docPar (docSetBaseY $ docSeq [docParenLSep, ieDsH])
$ docLines
$ ieDsT
++ [docParenR]
)
]

View File

@ -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
]