function updateResultSet(editor) {
        var cm = editor._codeMirror,
            state = getSearchState(cm);

        function indicateHasMatches(numResults) {
            // Make the field red if it's not blank and it has no matches (which also covers invalid regexes)
            findBar.showNoResults(!state.foundAny && findBar.getQueryInfo().query);

            // Navigation buttons enabled if we have a query and more than one match
            findBar.enableNavigation(state.foundAny && numResults > 1);
            findBar.enableReplace(state.foundAny);
        }

        cm.operation(function () {
            // Clear old highlights
            if (state.marked) {
                clearHighlights(cm, state);
            }

            if (!state.parsedQuery) {
                // Search field is empty - no results
                findBar.showFindCount("");
                state.foundAny = false;
                indicateHasMatches();
                return;
            }

            // Find *all* matches, searching from start of document
            // (Except on huge documents, where this is too expensive)
            var cursor = getSearchCursor(cm, state);
            if (cm.getValue().length <= FIND_MAX_FILE_SIZE) {
                // FUTURE: if last query was prefix of this one, could optimize by filtering last result set
                state.resultSet = [];
                while (cursor.findNext()) {
                    state.resultSet.push(cursor.pos);  // pos is unique obj per search result
                }

                // Highlight all matches if there aren't too many
                if (state.resultSet.length <= FIND_HIGHLIGHT_MAX) {
                    toggleHighlighting(editor, true);

                    state.resultSet.forEach(function (result) {
                        state.marked.push(cm.markText(result.from, result.to,
                             { className: "CodeMirror-searching", startStyle: "searching-first", endStyle: "searching-last" }));
                    });
                    var scrollTrackPositions = state.resultSet.map(function (result) {
                        return result.from;
                    });

                    ScrollTrackMarkers.addTickmarks(editor, scrollTrackPositions);
                }

                // Here we only update find bar with no result. In the case of a match
                // a findNext() call is guaranteed to be followed by this function call,
                // and findNext() in turn calls _updateFindBarWithMatchInfo() to show the
                // match index.
                if (state.resultSet.length === 0) {
                    findBar.showFindCount(Strings.FIND_NO_RESULTS);
                }

                state.foundAny = (state.resultSet.length > 0);
                indicateHasMatches(state.resultSet.length);

            } else {
                // On huge documents, just look for first match & then stop
                findBar.showFindCount("");
                state.foundAny = cursor.findNext();
                indicateHasMatches();
            }
        });
    }
Called each time the search query changes or document is modified (via Replace). Updates
the match count, match highlights and scrollbar tickmarks. Does not change the cursor pos.