@@ -874,6 +874,13 @@ def _compare_dicts(self, path, src, dst):
874874 self ._compare_values (path , key , src [key ], dst [key ])
875875
876876 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+
877884 len_src , len_dst = len (src ), len (dst )
878885 max_len = max (len_src , len_dst )
879886 min_len = min (len_src , len_dst )
@@ -889,7 +896,12 @@ def _compare_lists(self, path, src, dst):
889896
890897 elif isinstance (old , MutableSequence ) and \
891898 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 )
893905
894906 else :
895907 self ._item_removed (path , key , old )
0 commit comments