From 904a5ae9ea7a3b9d6963522bbb29b8bd43812164 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 11 Jul 2016 15:26:08 -0400 Subject: [PATCH] Use alignWith diffThese instead of zipWith so we don't drop children when diffing --- src/Interpreter.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Interpreter.hs b/src/Interpreter.hs index b8b3a4bc6..378798972 100644 --- a/src/Interpreter.hs +++ b/src/Interpreter.hs @@ -69,16 +69,16 @@ run construct comparable cost algorithm = case runFree algorithm of recur (MemberAccess a' as') (MemberAccess b' bs') = annotate $ MemberAccess (diffTerms' a' b') (diffTerms' as' bs') recur (SubscriptAccess a' as') (SubscriptAccess b' bs') = annotate $ SubscriptAccess (diffTerms' a' b') (diffTerms' as' bs') recur (MethodCall a' as' aParams') (MethodCall b' bs' bParams') = annotate $ MethodCall (diffTerms' a' b') (diffTerms' as' bs') (diffTerms' aParams' bParams') - recur (Ternary aCondition' aCases') (Ternary bCondition' bCases') = annotate $ Ternary (diffTerms' aCondition' bCondition') (zipWith diffTerms' aCases' bCases') - recur (Args as') (Args bs') = annotate . Args $ zipWith diffTerms' as' bs' + recur (Ternary aCondition' aCases') (Ternary bCondition' bCases') = annotate $ Ternary (diffTerms' aCondition' bCondition') (alignWith diffThese aCases' bCases') + recur (Args as') (Args bs') = annotate . Args $ alignWith diffThese as' bs' recur (VarDecl a') (VarDecl b') = annotate . VarDecl $ diffTerms' a' b' recur (VarAssignment a' as') (VarAssignment b' bs') = annotate $ VarAssignment (diffTerms' a' b') (diffTerms' as' bs') - recur (Operator a') (Operator b') = annotate $ Operator (zipWith diffTerms' a' b') + recur (Operator a') (Operator b') = annotate $ Operator (alignWith diffThese a' b') recur (Switch a' as') (Switch b' bs') = annotate $ Switch (diffTerms' a' b') (alignWith (these (pure . Delete) (pure . Insert) diffTerms') as' bs') recur (Case a' as') (Case b' bs') = annotate $ Case (diffTerms' a' b') (diffTerms' as' bs') - recur (Object as') (Object bs') = annotate $ Object (zipWith diffTerms' as' bs') + recur (Object as') (Object bs') = annotate $ Object (alignWith diffThese as' bs') recur (Pair a1 a2) (Pair b1 b2) = annotate $ Pair (diffTerms' a1 b1) (diffTerms' a2 b2) - recur (Commented a1 a2) (Commented b1 b2) = annotate $ Commented (zipWith diffTerms' a1 b1) (diffTerms' <$> a2 <*> b2) + recur (Commented a1 a2) (Commented b1 b2) = annotate $ Commented (alignWith diffThese a1 b1) (diffTerms' <$> a2 <*> b2) recur (Comment _) (Comment _) = pure $ Replace (cofree (annotation1 :< a)) (cofree (annotation2 :< b)) recur (Leaf _) (Leaf _) = pure $ Replace (cofree (annotation1 :< a)) (cofree (annotation2 :< b)) recur _ _ = pure $ Replace (cofree (annotation1 :< a)) (cofree (annotation2 :< b))