From 6fa7204728014692a4df8f1e808b93d3065225ed Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 19 Nov 2015 15:56:58 -0800 Subject: [PATCH] Accumulate context between children. --- src/Unified.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Unified.hs b/src/Unified.hs index 5a325c113..6e443fb71 100644 --- a/src/Unified.hs +++ b/src/Unified.hs @@ -23,9 +23,8 @@ unified diff before after = unifiedRange :: Range -> [(String, Maybe Range)] -> String -> String unifiedRange range children source = out ++ substring Range { start = previous, end = end range } after where (out, previous) = foldl accumulateContext ("", start range) children - accumulateContext (out, previous) (source, Just range) = (out ++ source, end range) - accumulateContext (out, previous) (source, _) = (out, previous) - + accumulateContext (out, previous) (child, Just range) = (out ++ substring Range { start = previous, end = start range } source ++ child, end range) + accumulateContext (out, previous) (child, _) = (out ++ child, previous) substring :: Range -> String -> String substring range = take (end range) . drop (start range)