diff --git a/src/SES.hs b/src/SES.hs index 4d3eedfc8..b8875a71d 100644 --- a/src/SES.hs +++ b/src/SES.hs @@ -11,8 +11,13 @@ ses :: Compare a -> [Term a Info] -> [Term a Info] -> [Diff a] ses _ [] b = (Pure . Insert) <$> b ses _ a [] = (Pure . Delete) <$> a ses recur (a : as) (b : bs) = case recur a b of - Just f -> f : ses recur as bs - Nothing -> if SES.cost delete < SES.cost insert then delete else insert where + Just f | SES.cost delete < SES.cost insert && SES.cost delete < SES.cost copy -> delete + | SES.cost insert < SES.cost copy -> insert + | otherwise -> copy + where + copy = f : ses recur as bs + Nothing -> if SES.cost delete < SES.cost insert then delete else insert + where delete = (Pure . Delete $ a) : ses recur as (b : bs) insert = (Pure . Insert $ b) : ses recur (a : as) bs