Omit single-line layout for OpApp with comments (fixes #111)
parent
a003b932a9
commit
3847325fd5
|
@ -538,6 +538,18 @@ cs0 = 0 : [ c / Interval n | c <- cs | n <- [1..] ]
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost
|
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost
|
||||||
|
|
||||||
|
#test issue 111
|
||||||
|
|
||||||
|
alternatives :: Parser (Maybe Text)
|
||||||
|
alternatives =
|
||||||
|
alternativeOne -- first try this one
|
||||||
|
<|> alterantiveTwo -- then this one
|
||||||
|
<|> alternativeThree -- then this one
|
||||||
|
where
|
||||||
|
alternativeOne = purer "one"
|
||||||
|
alternativeTwo = purer "two"
|
||||||
|
alterantiveThree = purer "three"
|
||||||
|
|
||||||
#test issue 116
|
#test issue 116
|
||||||
{-# LANGUAGE BangPatterns #-}
|
{-# LANGUAGE BangPatterns #-}
|
||||||
func = do
|
func = do
|
||||||
|
|
|
@ -237,24 +237,27 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
]
|
]
|
||||||
opLastDoc <- docSharedWrapper layoutExpr expOp
|
opLastDoc <- docSharedWrapper layoutExpr expOp
|
||||||
expLastDoc <- docSharedWrapper layoutExpr expRight
|
expLastDoc <- docSharedWrapper layoutExpr expRight
|
||||||
|
hasComments <- hasAnyCommentsBelow lexpr
|
||||||
let allowPar = case (expOp, expRight) of
|
let allowPar = case (expOp, expRight) of
|
||||||
(L _ (HsVar (L _ (Unqual occname))), _)
|
(L _ (HsVar (L _ (Unqual occname))), _)
|
||||||
| occNameString occname == "$" -> True
|
| occNameString occname == "$" -> True
|
||||||
(_, L _ (HsApp _ (L _ HsVar{}))) -> False
|
(_, L _ (HsApp _ (L _ HsVar{}))) -> False
|
||||||
_ -> True
|
_ -> True
|
||||||
docAlt
|
docAltFilter
|
||||||
[ docSeq
|
[ ( not hasComments
|
||||||
[ appSep $ docForceSingleline leftOperandDoc
|
|
||||||
, docSeq
|
, docSeq
|
||||||
$ (appListDocs <&> \(od, ed) -> docSeq
|
[ appSep $ docForceSingleline leftOperandDoc
|
||||||
[ appSep $ docForceSingleline od
|
, docSeq
|
||||||
, appSep $ docForceSingleline ed
|
$ (appListDocs <&> \(od, ed) -> docSeq
|
||||||
]
|
[ appSep $ docForceSingleline od
|
||||||
)
|
, appSep $ docForceSingleline ed
|
||||||
, appSep $ docForceSingleline opLastDoc
|
]
|
||||||
, (if allowPar then docForceParSpacing else docForceSingleline)
|
)
|
||||||
expLastDoc
|
, appSep $ docForceSingleline opLastDoc
|
||||||
]
|
, (if allowPar then docForceParSpacing else docForceSingleline)
|
||||||
|
expLastDoc
|
||||||
|
]
|
||||||
|
)
|
||||||
-- this case rather leads to some unfortunate layouting than to anything
|
-- this case rather leads to some unfortunate layouting than to anything
|
||||||
-- useful; disabling for now. (it interfers with cols stuff.)
|
-- useful; disabling for now. (it interfers with cols stuff.)
|
||||||
-- , docSetBaseY
|
-- , docSetBaseY
|
||||||
|
@ -264,12 +267,14 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
-- - $ (appListDocs <&> \(od, ed) -> docCols ColOpPrefix [appSep od, docSetBaseY ed])
|
-- - $ (appListDocs <&> \(od, ed) -> docCols ColOpPrefix [appSep od, docSetBaseY ed])
|
||||||
-- ++ [docCols ColOpPrefix [appSep opLastDoc, docSetBaseY expLastDoc]]
|
-- ++ [docCols ColOpPrefix [appSep opLastDoc, docSetBaseY expLastDoc]]
|
||||||
-- )
|
-- )
|
||||||
, docPar
|
, (otherwise
|
||||||
|
, docPar
|
||||||
leftOperandDoc
|
leftOperandDoc
|
||||||
( docLines
|
( docLines
|
||||||
$ (appListDocs <&> \(od, ed) -> docCols ColOpPrefix [appSep od, docSetBaseY ed])
|
$ (appListDocs <&> \(od, ed) -> docCols ColOpPrefix [appSep od, docSetBaseY ed])
|
||||||
++ [docCols ColOpPrefix [appSep opLastDoc, docSetBaseY expLastDoc]]
|
++ [docCols ColOpPrefix [appSep opLastDoc, docSetBaseY expLastDoc]]
|
||||||
)
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
OpApp expLeft expOp _ expRight -> do
|
OpApp expLeft expOp _ expRight -> do
|
||||||
expDocLeft <- docSharedWrapper layoutExpr expLeft
|
expDocLeft <- docSharedWrapper layoutExpr expLeft
|
||||||
|
|
Loading…
Reference in New Issue