Fix two column layouting bugs

pull/3/head
Lennart Spitzner 2016-08-12 00:32:06 +02:00
parent d30a712a75
commit b045c37bbd
2 changed files with 18 additions and 11 deletions

View File

@ -1192,17 +1192,22 @@ transformSimplifyIndent = Uniplate.rewrite $ \case
Just $ BDEnsureIndent ind $ BDLines $ lines ++ [indented] Just $ BDEnsureIndent ind $ BDLines $ lines ++ [indented]
BDPar ind (BDCols sig cols) indented -> BDPar ind (BDCols sig cols) indented ->
Just $ BDCols sig (List.init cols ++ [BDPar ind (List.last cols) indented]) Just $ BDCols sig (List.init cols ++ [BDPar ind (List.last cols) indented])
BDPar BrIndentNone _ _ -> Nothing
BDPar ind x indented -> BDPar ind x indented ->
Just $ BDLines Just $ BDPar BrIndentNone (BDAddBaseY ind x) (BDEnsureIndent ind indented)
[ BDAddBaseY ind x -- BDPar ind x indented ->
, BDEnsureIndent ind indented -- Just $ BDLines
] -- [ BDAddBaseY ind x
-- , BDEnsureIndent ind indented
-- ]
BDLines lines | any (\case BDLines{} -> True BDLines lines | any (\case BDLines{} -> True
BDEmpty{} -> True BDEmpty{} -> True
_ -> False) lines -> _ -> False) lines ->
Just $ BDLines $ filter isNotEmpty $ lines >>= \case Just $ BDLines $ filter isNotEmpty $ lines >>= \case
BDLines l -> l BDLines l -> l
x -> [x] x -> [x]
BDLines [l] ->
Just l
BDAddBaseY i (BDAnnotationPrior k x) -> BDAddBaseY i (BDAnnotationPrior k x) ->
Just $ BDAnnotationPrior k (BDAddBaseY i x) Just $ BDAnnotationPrior k (BDAddBaseY i x)
BDAddBaseY i (BDAnnotationKW k kw x) -> BDAddBaseY i (BDAnnotationKW k kw x) ->
@ -1244,8 +1249,9 @@ briDocLineLength briDoc = flip StateS.evalState False $ rec briDoc
BDAnnotationPrior _ bd -> rec bd BDAnnotationPrior _ bd -> rec bd
BDAnnotationKW _ _ bd -> rec bd BDAnnotationKW _ _ bd -> rec bd
BDAnnotationRest _ bd -> rec bd BDAnnotationRest _ bd -> rec bd
BDLines ls@(_:_) -> BDLines ls@(_:_) -> do
return $ maximum $ ls <&> \l -> StateS.evalState (rec l) False x <- StateS.get
return $ maximum $ ls <&> \l -> StateS.evalState (rec l) x
BDLines [] -> error "briDocLineLength BDLines []" BDLines [] -> error "briDocLineLength BDLines []"
BDEnsureIndent _ bd -> rec bd BDEnsureIndent _ bd -> rec bd
BDProhibitMTEL bd -> rec bd BDProhibitMTEL bd -> rec bd
@ -1552,7 +1558,8 @@ layoutBriDocM = \case
let fixedPosXs = if maxX>colMax let fixedPosXs = if maxX>colMax
then let then let
factor :: Float = factor :: Float =
max 1.0 ( fromIntegral (10 + colMax - curX) -- TODO: remove arbitrary 10.. -- 0.0001 as an offering to the floating point gods.
min 1.0001 ( fromIntegral (10 + colMax - curX) -- TODO: remove arbitrary 10..
/ fromIntegral (maxX - curX) / fromIntegral (maxX - curX)
) )
offsets = (subtract curX) <$> posXs offsets = (subtract curX) <$> posXs