function getTokenAt(cm, pos, precise) {
        if (precise) {
            _clearCache(); // reset cache
            return cm.getTokenAt(pos, precise);
        }
        var cachedTokens    = _manageCache(cm, pos.line),
            tokenIndex      = _.sortedIndex(cachedTokens, {end: pos.ch}, "end"), // binary search is faster for long arrays
            token           = cachedTokens[tokenIndex];
        return token || cm.getTokenAt(pos, precise); // fall back to CMs getTokenAt, for example in an empty line
    }
function getTokenAt(cm, pos, precise) {
        if (precise) {
            _clearCache(); // reset cache
            return cm.getTokenAt(pos, precise);
        }
        var cachedTokens    = _manageCache(cm, pos.line),
            tokenIndex      = _.sortedIndex(cachedTokens, {end: pos.ch}, "end"), // binary search is faster for long arrays
            token           = cachedTokens[tokenIndex];
        return token || cm.getTokenAt(pos, precise); // fall back to CMs getTokenAt, for example in an empty line
    }
function getTokenAt ( cm , pos , precise ) { if ( precise ) { _clearCache ( ) ; // reset cache return cm . getTokenAt ( pos , precise ) ; } var cachedTokens = _manageCache ( cm , pos . line ) , tokenIndex = _ . sortedIndex ( cachedTokens , { end : pos . ch } , "end" ) , // binary search is faster for long arrays token = cachedTokens [ tokenIndex ] ; return token || cm . getTokenAt ( pos , precise ) ; // fall back to CMs getTokenAt, for example in an empty line }
/*
Like cm.getTokenAt, but with caching. Way more performant for long lines.
@param {!CodeMirror} cm
@param {!{ch:number, line:number}} pos
@param {boolean} precise If given, results in more current results. Suppresses caching.
@return {Object} Token for position
/ * Like cm . getTokenAt but with caching . Way more performant for long lines .
Get a token from the cache