Superfluous change detected for simple swap/reverse case
If you diff {"reverse": [1, 5, 9]} with {"reverse": [9, 5, 1]}, two changes are reported:
move from index 2 to index 0
correct.
move from index 1 to index 1
Why?!
Seems to happen if there is an odd number of elements only.
it looks superflous but actually isn't (note you can't really do this in 1 movement, if you move 9 to index 0 the result is [9, 1, 5].
The reason is the movement indices are noted as "index at left state" => "index at right state" (so a 1 at the left, is not exactly the same as 1 at right, yes, sounds confusing).
It becomes clear seeing how array items movements are performed (when patching), it happens in this order:
- items are removed from their original (left) positions
- items are inserted in their final (right) positions
in this example, the sequence would be like this:
9is removed from index 2, result:[1, 5]5is removed from index 1, result:[1]- '9' is inserted at index 0, result:
[9, 1] 5is inserted at index 1, result:[9, 5, 1]
I see. But still, there shouldn't be an arrow from and to the very same item in the visualization, should there?
mm I guess the visualization is not clearest for these cases, as it doesn't represents the temporal intermediate steps. maybe arrows with identical start and end indices could be hidden, but I'm not sure, as there is something actually happening...