public override bool TryGetTokenFromInput(ITextCursor textCursor, out string token) { var match = false; token = null; if (ValidValues != null && ValidValues.Length > 0) { string matchText = null; var queryText = string.Empty; while (true) { var tokenPeek = textCursor.Peek(); if (string.IsNullOrWhiteSpace(tokenPeek)) { break; } if (textCursor.RightToLeftParsing) { queryText = $"{tokenPeek} {queryText}"; } else { queryText = $"{queryText} {tokenPeek}"; } queryText = queryText.Trim(); string[] matchTexts; if (textCursor.RightToLeftParsing) { matchTexts = ValidValues .Where(t => t.EndsWith(queryText, StringComparison.InvariantCultureIgnoreCase)) .OrderByDescending(t => t.Length) .ToArray(); } else { matchTexts = ValidValues .Where(t => t.StartsWith(queryText, StringComparison.InvariantCultureIgnoreCase)) .OrderByDescending(t => t.Length) .ToArray(); } if (matchTexts.Length >= 1) { // Avança o cursor textCursor.Next(); if (matchTexts.Any(t => t.Equals(queryText, StringComparison.InvariantCultureIgnoreCase))) { matchText = queryText; } } else { break; } } if (!string.IsNullOrEmpty(matchText)) { token = matchText; match = true; } } else { var queryText = textCursor.All(); if (!string.IsNullOrEmpty(queryText)) { token = queryText; match = true; } } return(match); }