@@ -840,13 +840,15 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
840840 if self ._count_diff () is StopIteration :
841841 return # pragma: no cover. This is already covered for addition.
842842
843+ reference_param1 = i
844+ reference_param2 = j
843845 if y is ListItemRemovedOrAdded : # item removed completely
844846 change_level = level .branch_deeper (
845847 x ,
846848 notpresent ,
847849 child_relationship_class = child_relationship_class ,
848- child_relationship_param = i ,
849- child_relationship_param2 = j ,
850+ child_relationship_param = reference_param1 ,
851+ child_relationship_param2 = reference_param2 ,
850852 )
851853 self ._report_result ('iterable_item_removed' , change_level , local_tree = local_tree )
852854
@@ -855,8 +857,8 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
855857 notpresent ,
856858 y ,
857859 child_relationship_class = child_relationship_class ,
858- child_relationship_param = i ,
859- child_relationship_param2 = j ,
860+ child_relationship_param = reference_param1 ,
861+ child_relationship_param2 = reference_param2 ,
860862 )
861863 self ._report_result ('iterable_item_added' , change_level , local_tree = local_tree )
862864
@@ -868,26 +870,30 @@ def _diff_by_forming_pairs_and_comparing_one_by_one(
868870 x ,
869871 y ,
870872 child_relationship_class = child_relationship_class ,
871- child_relationship_param = i ,
872- child_relationship_param2 = j
873+ child_relationship_param = reference_param1 ,
874+ child_relationship_param2 = reference_param2
873875 )
874876 self ._report_result ('iterable_item_moved' , change_level , local_tree = local_tree )
875877
878+ if self .iterable_compare_func :
879+ # Intentionally setting j as the first child relationship param in cases of a moved item.
880+ # If the item was moved using an iterable_compare_func then we want to make sure that the index
881+ # is relative to t2.
882+ reference_param1 = j
883+ reference_param2 = i
884+
876885 item_id = id (x )
877886 if parents_ids and item_id in parents_ids :
878887 continue
879888 parents_ids_added = add_to_frozen_set (parents_ids , item_id )
880889
881890 # Go one level deeper
882- # Intentionally setting j as the first child relationship param in cases of a moved item.
883- # If the item was moved using an iterable_compare_func then we want to make sure that the index
884- # is relative to t2.
885891 next_level = level .branch_deeper (
886892 x ,
887893 y ,
888894 child_relationship_class = child_relationship_class ,
889- child_relationship_param = j ,
890- child_relationship_param2 = i
895+ child_relationship_param = reference_param1 ,
896+ child_relationship_param2 = reference_param2
891897 )
892898 self ._diff (next_level , parents_ids_added , local_tree = local_tree )
893899
0 commit comments