Skip to content

Commit 6c0ffe5

Browse files
committed
fixed incorrect index computation for ordered collection tail removal
1 parent ec25795 commit 6c0ffe5

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

SharpDiffLib.Test/Diff/ArrayOfPrimitives.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void TwoRemoved()
8282
{
8383
const string diff =
8484
"-2:2\r\n" +
85-
"-2:3";
85+
"-3:3";
8686
var @base = new[] { 1, 2, 2, 3 };
8787
var changed = new[] { 1, 2 };
8888

@@ -211,10 +211,10 @@ public void AllRemoved()
211211
{
212212
const string diff =
213213
"-0:2\r\n" +
214-
"-0:2\r\n" +
215-
"-0:2\r\n" +
216-
"-0:2\r\n" +
217-
"-0:2";
214+
"-1:2\r\n" +
215+
"-2:2\r\n" +
216+
"-3:2\r\n" +
217+
"-4:2";
218218
var @base = new[] { 2, 2, 2, 2, 2 };
219219
var changed = new int[] { };
220220

SharpDiffLib/algorithms/diff/collection/ordered/OrderedCollectionDiff.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ private IDiff<TType> ComputeInternal(IEnumerable<TItemType> @base, IEnumerable<T
187187
}
188188
}
189189
else if (baseHasItem)
190+
{
190191
ret.Add(new DiffOrderedCollectionRemoved<TItemType>(index, baseItem));
192+
index++;
193+
}
191194
else if (changedHasItem)
192195
ret.Add(new DiffOrderedCollectionAdded<TItemType>(index, changedItem));
193196
else

0 commit comments

Comments
 (0)