src/search/FindReplace.js
function _findAllAndSelect(editor) {
        editor = editor || EditorManager.getActiveEditor();
        if (!editor) {
            return;
        }

        var sel = editor.getSelection(),
            newSelections = [];
        if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
            sel = _getWordAt(editor, sel.start);
        }
        if (CodeMirror.cmpPos(sel.start, sel.end) !== 0) {
            var searchStart = {line: 0, ch: 0},
                state = getSearchState(editor._codeMirror),
                nextMatch;
            setQueryInfo(state, { query: editor.document.getRange(sel.start, sel.end), isCaseSensitive: false, isRegexp: false });

            while ((nextMatch = _getNextMatch(editor, false, searchStart, false)) !== null) {
                if (_selEq(sel, nextMatch)) {
                    nextMatch.primary = true;
                }
                newSelections.push(nextMatch);
                searchStart = nextMatch.end;
            }

            // This should find at least the original selection, but just in case...
            if (newSelections.length) {
                // Don't change the scroll position.
                editor.setSelections(newSelections, false);
            }
        }
    }
function _findAllAndSelect(editor) {
        editor = editor || EditorManager.getActiveEditor();
        if (!editor) {
            return;
        }

        var sel = editor.getSelection(),
            newSelections = [];
        if (CodeMirror.cmpPos(sel.start, sel.end) === 0) {
            sel = _getWordAt(editor, sel.start);
        }
        if (CodeMirror.cmpPos(sel.start, sel.end) !== 0) {
            var searchStart = {line: 0, ch: 0},
                state = getSearchState(editor._codeMirror),
                nextMatch;
            setQueryInfo(state, { query: editor.document.getRange(sel.start, sel.end), isCaseSensitive: false, isRegexp: false });

            while ((nextMatch = _getNextMatch(editor, false, searchStart, false)) !== null) {
                if (_selEq(sel, nextMatch)) {
                    nextMatch.primary = true;
                }
                newSelections.push(nextMatch);
                searchStart = nextMatch.end;
            }

            // This should find at least the original selection, but just in case...
            if (newSelections.length) {
                // Don't change the scroll position.
                editor.setSelections(newSelections, false);
            }
        }
    }
function _findAllAndSelect ( editor ) { editor = editor || EditorManager . getActiveEditor ( ) ; if ( ! editor ) { return ; } var sel = editor . getSelection ( ) , newSelections = [ ] ; if ( CodeMirror . cmpPos ( sel . start , sel . end ) === 0 ) { sel = _getWordAt ( editor , sel . start ) ; } if ( CodeMirror . cmpPos ( sel . start , sel . end ) !== 0 ) { var searchStart = { line : 0 , ch : 0 } , state = getSearchState ( editor . _codeMirror ) , nextMatch ; setQueryInfo ( state , { query : editor . document . getRange ( sel . start , sel . end ) , isCaseSensitive : false , isRegexp : false } ) ; while ( ( nextMatch = _getNextMatch ( editor , false , searchStart , false ) ) !== null ) { if ( _selEq ( sel , nextMatch ) ) { nextMatch . primary = true ; } newSelections . push ( nextMatch ) ; searchStart = nextMatch . end ; } // This should find at least the original selection, but just in case... if ( newSelections . length ) { // Don't change the scroll position. editor . setSelections ( newSelections , false ) ; } } }
Takes the primary selection, expands it to a word range if necessary, then sets the selection to
include all instances of that range. Removes all other selections. Does nothing if the selection
is not a range after expansion.
Takes the primary selection expands it to a word range if necessary then sets the selection to include all instances of that range . Removes all other selections . Does nothing if the selection is not a range after expansion .