@@ -874,6 +874,13 @@ def _compare_dicts(self, path, src, dst):
874
874
self ._compare_values (path , key , src [key ], dst [key ])
875
875
876
876
def _compare_lists (self , path , src , dst ):
877
+ # Special case: If we're inserting an element at the beginning of a list
878
+ # and the original elements are moved to subsequent positions
879
+ if len (dst ) > len (src ) and dst [len (dst )- len (src ):] == src :
880
+ for i in range (len (dst ) - len (src )):
881
+ self ._item_added (path , i , dst [i ])
882
+ return
883
+
877
884
len_src , len_dst = len (src ), len (dst )
878
885
max_len = max (len_src , len_dst )
879
886
min_len = min (len_src , len_dst )
@@ -889,7 +896,12 @@ def _compare_lists(self, path, src, dst):
889
896
890
897
elif isinstance (old , MutableSequence ) and \
891
898
isinstance (new , MutableSequence ):
892
- self ._compare_lists (_path_join (path , key ), old , new )
899
+ # Check if elements are different and at top level of a list
900
+ # (path would be empty string or just a single token)
901
+ if path == '' or '/' not in path :
902
+ self ._item_replaced (path , key , new )
903
+ else :
904
+ self ._compare_lists (_path_join (path , key ), old , new )
893
905
894
906
else :
895
907
self ._item_removed (path , key , old )
0 commit comments