public static ISegment GetSingleIndentationSegment(ITextSource textSource, int offset, int indentationSize)
{
if (textSource == null)
throw new ArgumentNullException("textSource");
var pos = offset;
while (pos < textSource.TextLength)
{
var c = textSource.GetCharAt(pos);
if (c == '\t')
{
if (pos == offset)
return new SimpleSegment(offset, 1);
break;
}
if (c == ' ')
{
if (pos - offset >= indentationSize)
break;
}
else
{
break;
}
// continue only if c==' ' and (pos-offset)<tabSize
pos++;
}
return new SimpleSegment(offset, pos - offset);
}