Skip to content

Commit e4644ee

Browse files
committed
fix(XMLDiff): rename variable for clarity in tracking removed or replaced elements
1 parent b639741 commit e4644ee

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

XMLDiff/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ private static bool CompareElements(
491491

492492
int i = 0,
493493
j = 0;
494-
int lastRemoved = -1;
494+
int lastRemovedOrReplaced = -1;
495495
while (i < originalChildren.Count && j < modifiedChildren.Count)
496496
{
497497
var originalChild = originalChildren[i];
@@ -649,7 +649,7 @@ private static bool CompareElements(
649649
{
650650
string xpath = GenerateXPath(originalChildren[i - 1], pathOptions);
651651
string pos = "after";
652-
if (lastRemoved == i - 1 || NumericIdsPattern.IsMatch(xpath))
652+
if (lastRemovedOrReplaced == i - 1 || NumericIdsPattern.IsMatch(xpath))
653653
{
654654
string xpathBefore = GenerateXPath(originalChild, pathOptions);
655655
if (!NumericIdsPattern.IsMatch(xpathBefore))
@@ -699,6 +699,7 @@ private static bool CompareElements(
699699
{
700700
string sel = GenerateXPath(originalChild, pathOptions);
701701
XElement replaceOp = new XElement("replace", new XAttribute("sel", sel), modifiedChild);
702+
lastRemovedOrReplaced = i;
702703
diffRoot.Add(replaceOp);
703704
Logger.Info($"[Operation replace] Element '{GetElementInfo(originalChild)}' with '{GetElementInfo(modifiedChild)}'.");
704705
i++;
@@ -708,7 +709,7 @@ private static bool CompareElements(
708709
{
709710
string sel = GenerateXPath(originalChild, pathOptions);
710711
XElement removeOp = new XElement("remove", new XAttribute("sel", sel));
711-
lastRemoved = i;
712+
lastRemovedOrReplaced = i;
712713
diffRoot.Add(removeOp);
713714
Logger.Info($"[Operation remove] Element '{GetElementInfo(originalChild)}' from parent '{GetElementInfo(originalElem)}'.");
714715
i++;
@@ -722,7 +723,7 @@ private static bool CompareElements(
722723
var originalChild = originalChildren[i];
723724
string sel = GenerateXPath(originalChild, pathOptions);
724725
XElement removeOp = new XElement("remove", new XAttribute("sel", sel));
725-
lastRemoved = i;
726+
lastRemovedOrReplaced = i;
726727
diffRoot.Add(removeOp);
727728
Logger.Info($"[Operation remove] Element '{GetElementInfo(originalChild)}' from parent '{GetElementInfo(originalElem)}'.");
728729
i++;

0 commit comments

Comments
 (0)