Microsoft.Languages.Core.Formatting.IndentBuilder.TextIndentInSpaces C# (CSharp) Метод

TextIndentInSpaces() публичный статический Метод

Given text string (typically content of a text buffer) calculates size of indentation (length of the leading whitespace in the line) in spaces.
public static TextIndentInSpaces ( string text, int tabSize ) : int
text string
tabSize int
Результат int
        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;
        }