1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Replacements advance past the maximal id in the before state.

This commit is contained in:
Rob Rix 2017-12-18 11:29:34 -05:00
parent 3ae354b750
commit 5f49f4589c

View File

@ -30,8 +30,8 @@ diffAlgebra d i = case d of
Merge t -> termAlgebra t i Merge t -> termAlgebra t i
Patch (Delete t1) -> termAlgebra t1 i `modifyHeadNode` setColour "red" Patch (Delete t1) -> termAlgebra t1 i `modifyHeadNode` setColour "red"
Patch (Insert t2) -> termAlgebra t2 i `modifyHeadNode` setColour "green" Patch (Insert t2) -> termAlgebra t2 i `modifyHeadNode` setColour "green"
Patch (Replace t1 t2) -> let r1 = termAlgebra t1 i `modifyHeadNode` setColour "red" Patch (Replace t1 t2) -> let r1 = termAlgebra t1 i `modifyHeadNode` setColour "red"
in r1 <> termAlgebra t2 (succ (maximum (i : fst r1))) `modifyHeadNode` setColour "green" in r1 <> termAlgebra t2 (succ (maximum (i : map nodeID (graphNodes (snd r1))))) `modifyHeadNode` setColour "green"
where modifyHeadNode (i, g) f | n:ns <- graphNodes g = (i, g { graphNodes = f n : ns }) where modifyHeadNode (i, g) f | n:ns <- graphNodes g = (i, g { graphNodes = f n : ns })
| otherwise = (i, g) | otherwise = (i, g)
setColour c n = n { nodeAttributes = Map.insert "color" c (nodeAttributes n) } setColour c n = n { nodeAttributes = Map.insert "color" c (nodeAttributes n) }