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