1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 21:01:35 +03:00

Use the element’s index for replacements/comparisons.

This commit is contained in:
Rob Rix 2016-07-05 16:23:28 -04:00
parent 1037bab2d6
commit ef916364e5

View File

@ -41,7 +41,7 @@ rws compare getLabel as bs
Nothing -> pure (negate 1, insert v) Nothing -> pure (negate 1, insert v)
Just (i, found) -> do Just (i, found) -> do
put (List.delete (k, (i, found)) unmapped) put (List.delete (k, (i, found)) unmapped)
pure (negate 1, fromMaybe (replace found v) (compare found v)) pure (i, fromMaybe (replace found v) (compare found v))
deleteRemaining diffs unmapped = foldl' (flip (List.insertBy (comparing fst))) diffs (second delete . snd <$> unmapped) deleteRemaining diffs unmapped = foldl' (flip (List.insertBy (comparing fst))) diffs (second delete . snd <$> unmapped)
-- | Extract the annotation for the before state of a diff node. This is returned in `Maybe` because e.g. an `Insert` patch does not have an annotation for the before state. -- | Extract the annotation for the before state of a diff node. This is returned in `Maybe` because e.g. an `Insert` patch does not have an annotation for the before state.