Microsoft.Languages.Core.Formatting.IndentBuilder.TextLengthInSpaces C# (CSharp) Method

TextLengthInSpaces() public static method

Calculates length of text in spaces, converting tabs to spaces using specified tab size.
public static TextLengthInSpaces ( string text, int tabSize ) : int
text string
tabSize int
return int
        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;
        }