/// <summary>
/// Calculates length of text in spaces, converting tabs to spaces using specified tab size.
/// </summary>
public static int TextLengthInSpaces(string text, int tabSize)
{
var length = 0;
var spaces = 0;
for (var i = 0; i < text.Length; i++)
{
var ch = text[i];
if (ch.IsLineBreak())
{
break;
}
length += IndentBuilder.GetWhiteSpaceCharLength(ch, spaces, tabSize);
if (ch == ' ')
{
spaces++;
}
}
return(length);
}