Fix for issue #782 (CPIndexSet shiftIndexesStartingAtIndex:by: bug)

This commit is contained in:
Aparajita Fishman committed 2010-07-28 19:03:43 -04:00
1 parent cdb2013427
commit fdd7a8d2bc
2 files changed
+9 -2

No files matched your search

+2 -2
View File
@@ -698,12 +698,12 @@
var range = _ranges[i],
maximum = CPMaxRange(range);
if (anIndex > maximum)
if (anIndex >= maximum)
break;
// If our index is within our range, but not the first index,
// then this range will be split.
if (anIndex > range.location && anIndex < maximum)
if (anIndex > range.location)
{
// Split the range into shift and unshifted.
shifted = CPMakeRange(anIndex + aDelta, maximum - anIndex);
+7
View File
@@ -366,6 +366,13 @@ function descriptionWithoutEntity(aString)
// negative delta for downward shift
[_set shiftIndexesStartingAtIndex:1 by:-1];
[self assertTrue:[_set containsIndexes:[CPIndexSet indexSetWithIndexesInRange:startRange]]];
// test for fix to issue #746 (last item is mistakenly shifted)
_set = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 1)];
[self assertTrue:[_set lastIndex] === 0];
[_set shiftIndexesStartingAtIndex:[_set lastIndex] + 1 by:1];
[self assertTrue:[_set lastIndex] === 0];
}
- (void)tearDown