Skip to content

Commit eb05c82

Browse files
committed
fix(XMLDiff): get back enhanced element comparison logic to handle next matched elements correctly
1 parent 3485f06 commit eb05c82

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

XMLDiff/Program.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,24 @@ private static bool CompareElements(
598598
matchedEnough = false;
599599
if (!CompareElements(original, modified, diffRoot, pathOptions, originalChild, modifiedChild, true))
600600
{
601-
if (savedOp != null)
601+
bool nextMatched = true;
602+
if (i + 1 < originalChildren.Count && j + 1 < modifiedChildren.Count)
602603
{
603-
diffRoot.Add(savedOp);
604-
Logger.Info($"[Operation {savedOp.Name}] Added the saved operation to the diff.");
604+
XElement originalTemp = new XElement("temp");
605+
originalTemp.Add(originalChildren[i + 1]);
606+
XElement modifiedTemp = new XElement("temp");
607+
modifiedTemp.Add(modifiedChildren[j + 1]);
608+
nextMatched = !CompareElements(original, modified, diffRoot, pathOptions, originalTemp, modifiedTemp, true);
609+
}
610+
if (nextMatched)
611+
{
612+
if (savedOp != null)
613+
{
614+
diffRoot.Add(savedOp);
615+
Logger.Info($"[Operation {savedOp.Name}] Added the saved operation to the diff.");
616+
}
617+
matchedEnough = true;
605618
}
606-
matchedEnough = true;
607619
}
608620
}
609621
Logger.Debug($"Matched enough: {matchedEnough}, i: {i}, j: {j}");

0 commit comments

Comments
 (0)