From 59e6577f5e1f0c0dc33b5c3a77803103bb3bd1ef Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 4 Dec 2015 10:43:45 -0500 Subject: [PATCH] Correct the accumulation of the terminal context. --- src/Split.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Split.hs b/src/Split.hs index e13e8f5a9..b865dca46 100644 --- a/src/Split.hs +++ b/src/Split.hs @@ -47,7 +47,11 @@ annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCatego annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCategories) (Indexed i)) before after = (bimap (Ul $ classify leftCategories) (Ul $ classify rightCategories) <$> rows, left, right) where rows = appendRemainder $ foldl sumRows ([], start left, start right) i - appendRemainder (rows, previousLeft, previousRight) = adjoinRows rows [ Row (Text <$> lines (substring (Range previousLeft $ end left) before)) (Text <$> lines (substring (Range previousRight $ end right) after)) ] + appendRemainder (rows, previousLeft, previousRight) = adjoinRows rows contextRows + where + contextRows = uncurry rowFromMaybeRows <$> zipMaybe leftElements rightElements + leftElements = Text <$> lines (substring (Range previousLeft $ end left) before) + rightElements = Text <$> lines (substring (Range previousRight $ end right) after) sumRows (rows, previousLeft, previousRight) child = (rows `adjoinRows` contextRows `adjoinRows` childRows, end leftChildRange, end rightChildRange) where (childRows, leftChildRange, rightChildRange) = diffToRows child before after