private int FindPositionInRange(int startPosition, int endPosition, bool direction, CharType charTypeFlags)
{
if (startPosition < 0)
{
startPosition = 0;
}
if (endPosition >= _testString.Length)
{
endPosition = _testString.Length - 1;
}
if (startPosition > endPosition)
{
return invalidIndex;
}
// Iterate through the test string until we find an edit char position.
int testPosition;
while (startPosition <= endPosition)
{
testPosition = (direction == forward) ? startPosition++ : endPosition--;
CharDescriptor chDex = _stringDescriptor[testPosition];
if ((chDex.CharType & charTypeFlags) == chDex.CharType)
{
return testPosition;
}
}
return invalidIndex;
}