src/utils/StringMatch.js
function backtrack() {

            // The idea is to pull matches off of our match list, rolling back
            // characters from the query. We pay special attention to the special
            // characters since they are searched first.
            while (result.length > 0) {
                var item = result.pop();

                // nothing in the list? there's no possible match then.
                if (!item) {
                    return false;
                }

                // we pulled off a match, which means that we need to put a character
                // back into our query. strCounter is going to be set once we've pulled
                // off the right special character and know where we're going to restart
                // searching from.
                queryCounter--;

                if (item instanceof SpecialMatch) {
                    // pulled off a special, which means we need to make that special available
                    // for matching again
                    specialsCounter--;

                    // check to see if we've gone back as far as we need to
                    if (item.index < deadBranches[queryCounter]) {
                        // we now know that this part of the query does not match beyond this
                        // point
                        deadBranches[queryCounter] = item.index - 1;

                        // since we failed with the specials along this track, we're
                        // going to reset to looking for matches consecutively.
                        state = ANY_MATCH;

                        // we figure out where to start looking based on the new
                        // last item in the list. If there isn't anything else
                        // in the match list, we'll start over at the starting special
                        // (which is generally the beginning of the string, or the
                        // beginning of the last segment of the string)
                        item = result[result.length - 1];
                        if (!item) {
                            strCounter = specials[startingSpecial] + 1;
                            return true;
                        }
                        strCounter = item.index + 1;
                        return true;
                    }
                }
            }
            return false;
        }
function backtrack() {

            // The idea is to pull matches off of our match list, rolling back
            // characters from the query. We pay special attention to the special
            // characters since they are searched first.
            while (result.length > 0) {
                var item = result.pop();

                // nothing in the list? there's no possible match then.
                if (!item) {
                    return false;
                }

                // we pulled off a match, which means that we need to put a character
                // back into our query. strCounter is going to be set once we've pulled
                // off the right special character and know where we're going to restart
                // searching from.
                queryCounter--;

                if (item instanceof SpecialMatch) {
                    // pulled off a special, which means we need to make that special available
                    // for matching again
                    specialsCounter--;

                    // check to see if we've gone back as far as we need to
                    if (item.index < deadBranches[queryCounter]) {
                        // we now know that this part of the query does not match beyond this
                        // point
                        deadBranches[queryCounter] = item.index - 1;

                        // since we failed with the specials along this track, we're
                        // going to reset to looking for matches consecutively.
                        state = ANY_MATCH;

                        // we figure out where to start looking based on the new
                        // last item in the list. If there isn't anything else
                        // in the match list, we'll start over at the starting special
                        // (which is generally the beginning of the string, or the
                        // beginning of the last segment of the string)
                        item = result[result.length - 1];
                        if (!item) {
                            strCounter = specials[startingSpecial] + 1;
                            return true;
                        }
                        strCounter = item.index + 1;
                        return true;
                    }
                }
            }
            return false;
        }
function backtrack ( ) { // The idea is to pull matches off of our match list, rolling back // characters from the query. We pay special attention to the special // characters since they are searched first. while ( result . length > 0 ) { var item = result . pop ( ) ; // nothing in the list? there's no possible match then. if ( ! item ) { return false ; } // we pulled off a match, which means that we need to put a character // back into our query. strCounter is going to be set once we've pulled // off the right special character and know where we're going to restart // searching from. queryCounter -- ; if ( item instanceof SpecialMatch ) { // pulled off a special, which means we need to make that special available // for matching again specialsCounter -- ; // check to see if we've gone back as far as we need to if ( item . index < deadBranches [ queryCounter ] ) { // we now know that this part of the query does not match beyond this // point deadBranches [ queryCounter ] = item . index - 1 ; // since we failed with the specials along this track, we're // going to reset to looking for matches consecutively. state = ANY_MATCH ; // we figure out where to start looking based on the new // last item in the list. If there isn't anything else // in the match list, we'll start over at the starting special // (which is generally the beginning of the string, or the // beginning of the last segment of the string) item = result [ result . length - 1 ] ; if ( ! item ) { strCounter = specials [ startingSpecial ] + 1 ; return true ; } strCounter = item . index + 1 ; return true ; } } } return false ; }
This function implements the backtracking that is done when we fail to find a match with the query using the "search for specials first" approach.  returns false when it is not able to backtrack successfully
This function implements the backtracking that is done when we fail to find a match with the query using the search for specials first approach . returns false when it is not able to backtrack successfully