private static TokenPosition LocateSubtoken(string filePath, string searchText, bool fullTokensOnly, EditorInfo editorInfo)
 {
     int startLine = 1;
     int startColumnInFirstLine = 0;
     if (editorInfo != null)
     {
         startLine = editorInfo.CurrentLineNum;
         startColumnInFirstLine = editorInfo.CurrentColumn;
     }
     int queryLen = searchText.Length;
     var bestSubtokenPosition = new TokenPosition(-1, 0, 0);
     foreach (LineInfo lineInfo in FileReader.ReadFileAsEnumerableWithWrap(filePath, startLine))
     {
         int columnsToIgnore = (lineInfo.LineNumber == startLine ? startColumnInFirstLine : 0);
         TokenPosition tokenPos = GetLongestSubtoken(lineInfo.LineNumber, lineInfo.LineText, searchText, columnsToIgnore);
         if (tokenPos.MatchLength > bestSubtokenPosition.MatchLength)
         {
             bestSubtokenPosition = tokenPos;
             if (tokenPos.MatchLength == queryLen)
             {
                 break;
             }
         }
     }
     if (fullTokensOnly && bestSubtokenPosition.MatchLength != queryLen)
     {
         return new TokenPosition(-1, 0, 0);
     }
     return bestSubtokenPosition;
 }
 private TokenPosition LocateSubtoken(string filePath, SearchOptions searchOptions, bool fullTokensOnly, EditorInfo editorInfo)
 {
     int startLine = 1;
     int startColumnInFirstLine = 0;
     if (editorInfo != null)
     {
         startLine = editorInfo.CurrentLineNum;
         startColumnInFirstLine = editorInfo.CurrentColumn;
     }
     string searchText = searchOptions.SearchText;
     if (!searchOptions.SearchRegex)
     {
         searchText = searchText.Replace("\"", string.Empty);
     }
     int queryLen = searchText.Length;
     var bestSubtokenPosition = new TokenPosition(-1, 0, 0);
     Regex regex = searchOptions.SearchRegex ? new Regex(searchText, RegexOptions.Compiled | RegexOptions.IgnoreCase) : null;
     bool firstLine = true;
     foreach (LineInfo lineInfo in fileReader.ReadFileAsEnumerableWithWrap(filePath, startLine))
     {
         int columnsToIgnore = (firstLine ? startColumnInFirstLine : 0);
         firstLine = false;
         TokenPosition tokenPos = GetLongestSubtoken(lineInfo.LineNumber, lineInfo.LineText, searchText, regex, columnsToIgnore);
         if (tokenPos.MatchLength > bestSubtokenPosition.MatchLength)
         {
             bestSubtokenPosition = tokenPos;
             if (tokenPos.MatchLength == queryLen)
             {
                 break;
             }
         }
     }
     if (!searchOptions.SearchRegex && fullTokensOnly && bestSubtokenPosition.MatchLength != queryLen)
     {
         return new TokenPosition(-1, 0, 0);
     }
     return bestSubtokenPosition;
 }
 public TokenPosition LocateNextToken(string filePath, SearchOptions searchOptions, EditorInfo editorInfo)
 {
     return LocateSubtoken(filePath, searchOptions, true, editorInfo);
 }
 public static TokenPosition LocateNextToken(string filePath, string searchText, EditorInfo editorInfo)
 {
     return LocateSubtoken(filePath, searchText, true, editorInfo);
 }