PowerArgs.Cli.RichCommandLineContext.GetQuoteStatus C# (CSharp) Method

GetQuoteStatus() private method

private GetQuoteStatus ( List chars, int startPosition ) : QuoteStatus
chars List
startPosition int
return QuoteStatus
        private QuoteStatus GetQuoteStatus(List<ConsoleCharacter> chars, int startPosition)
        {
            bool open = false;

            for (int i = 0; i <= startPosition; i++)
            {
                var c = chars[i];
                if (i > 0 && c == '"' && chars[i - 1] == '\\')
                {
                    // escaped
                }
                else if (c == '"')
                {
                    open = !open;
                }
            }

            if (open) return QuoteStatus.OpenedQuote;

            if (chars.LastIndexOf(new ConsoleCharacter('"')) > chars.LastIndexOf(new ConsoleCharacter(' '))) return QuoteStatus.ClosedQuote;
            return QuoteStatus.NoQuotes;
        }