function _wholeStringSearch(queryLower, compareLower, originalQuery, originalStr, specials, lastSegmentSpecialsIndex) {
        var lastSegmentStart = specials[lastSegmentSpecialsIndex];
        var result;
        var matchList;

        result = _lastSegmentSearch(queryLower, compareLower, originalQuery, originalStr, specials, lastSegmentSpecialsIndex, lastSegmentStart);

        if (result) {
            matchList = result.matchList;

            // Do we have more query characters that did not fit?
            if (result.remainder) {
                // Scan with the remainder only through the beginning of the last segment
                var remainderMatchList = _generateMatchList(result.remainder,
                                              compareLower.substring(0, lastSegmentStart),
                                              result.originalRemainder,
                                              originalStr.substring(0, lastSegmentStart),
                                              specials.slice(0, lastSegmentSpecialsIndex), 0);

                if (remainderMatchList) {
                    // add the new matched ranges to the beginning of the set of ranges we had
                    matchList.unshift.apply(matchList, remainderMatchList);
                } else {
                    // no match
                    return null;
                }
            }
        } else {
            // No match in the last segment, so we start over searching the whole
            // string
            matchList = _generateMatchList(queryLower, compareLower, originalQuery, originalStr, specials, 0);
        }

        return matchList;
    }
function _wholeStringSearch(queryLower, compareLower, originalQuery, originalStr, specials, lastSegmentSpecialsIndex) {
        var lastSegmentStart = specials[lastSegmentSpecialsIndex];
        var result;
        var matchList;

        result = _lastSegmentSearch(queryLower, compareLower, originalQuery, originalStr, specials, lastSegmentSpecialsIndex, lastSegmentStart);

        if (result) {
            matchList = result.matchList;

            // Do we have more query characters that did not fit?
            if (result.remainder) {
                // Scan with the remainder only through the beginning of the last segment
                var remainderMatchList = _generateMatchList(result.remainder,
                                              compareLower.substring(0, lastSegmentStart),
                                              result.originalRemainder,
                                              originalStr.substring(0, lastSegmentStart),
                                              specials.slice(0, lastSegmentSpecialsIndex), 0);

                if (remainderMatchList) {
                    // add the new matched ranges to the beginning of the set of ranges we had
                    matchList.unshift.apply(matchList, remainderMatchList);
                } else {
                    // no match
                    return null;
                }
            }
        } else {
            // No match in the last segment, so we start over searching the whole
            // string
            matchList = _generateMatchList(queryLower, compareLower, originalQuery, originalStr, specials, 0);
        }

        return matchList;
    }
function _wholeStringSearch ( queryLower , compareLower , originalQuery , originalStr , specials , lastSegmentSpecialsIndex ) { var lastSegmentStart = specials [ lastSegmentSpecialsIndex ] ; var result ; var matchList ; result = _lastSegmentSearch ( queryLower , compareLower , originalQuery , originalStr , specials , lastSegmentSpecialsIndex , lastSegmentStart ) ; if ( result ) { matchList = result . matchList ; // Do we have more query characters that did not fit? if ( result . remainder ) { // Scan with the remainder only through the beginning of the last segment var remainderMatchList = _generateMatchList ( result . remainder , compareLower . substring ( 0 , lastSegmentStart ) , result . originalRemainder , originalStr . substring ( 0 , lastSegmentStart ) , specials . slice ( 0 , lastSegmentSpecialsIndex ) , 0 ) ; if ( remainderMatchList ) { // add the new matched ranges to the beginning of the set of ranges we had matchList . unshift . apply ( matchList , remainderMatchList ) ; } else { // no match return null ; } } } else { // No match in the last segment, so we start over searching the whole // string matchList = _generateMatchList ( queryLower , compareLower , originalQuery , originalStr , specials , 0 ) ; } return matchList ; }
/*
Implements the top-level search algorithm. Search the last segment first,
then search the rest of the string with the remainder.

The parameters and return value are the same as for getMatchRanges.

@param {string} queryLower the search string (will be searched lower case)
@param {string} compareLower the lower-cased string to search
@param {string} originalQuery the "non-normalized" query string (used to detect case match priority)
@param {string} originalStr the "non-normalized" string to compare with (used to detect case match priority)
@param {Array} specials list of special indexes in str (from findSpecialCharacters)
@param {int} lastSegmentSpecialsIndex index into specials array to start scanning with
@return {Array.<SpecialMatch|NormalMatch>} matched indexes or null if no matches possible
/ * Implements the top - level search algorithm . Search the last segment first then search the rest of the string with the remainder .
Search the whole string in the string