public static int TextLengthInSpaces(string text, int tabSize) {
int length = 0;
int spaces = 0;
for (int i = 0; i < text.Length; i++) {
char ch = text[i];
if (ch.IsLineBreak())
break;
length += IndentBuilder.GetWhiteSpaceCharLength(ch, spaces, tabSize);
if (ch == ' ')
spaces++;
}
return length;
}