public/javascripts/codemirror/js/editor.js
function tryFindMatch() {
        var stack = [], ch, ok = true;;
        for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {
          if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {
            if (forward(ch) == dir)
              stack.push(ch);
            else if (!stack.length)
              ok = false;
            else if (stack.pop() != matching[ch])
              ok = false;
            if (!stack.length) break;
          }
          else if (runner.dirty || !isSpan(runner) && !isBR(runner)) {
            return {node: runner, status: "dirty"};
          }
        }
        return {node: runner, status: runner && ok};
      }
function tryFindMatch() {
        var stack = [], ch, ok = true;;
        for (var runner = cursor; runner; runner = dir ? runner.nextSibling : runner.previousSibling) {
          if (runner.className == className && isSpan(runner) && (ch = paren(runner))) {
            if (forward(ch) == dir)
              stack.push(ch);
            else if (!stack.length)
              ok = false;
            else if (stack.pop() != matching[ch])
              ok = false;
            if (!stack.length) break;
          }
          else if (runner.dirty || !isSpan(runner) && !isBR(runner)) {
            return {node: runner, status: "dirty"};
          }
        }
        return {node: runner, status: runner && ok};
      }
function tryFindMatch ( ) { var stack = [ ] , ch , ok = true ; ; for ( var runner = cursor ; runner ; runner = dir ? runner . nextSibling : runner . previousSibling ) { if ( runner . className == className && isSpan ( runner ) && ( ch = paren ( runner ) ) ) { if ( forward ( ch ) == dir ) stack . push ( ch ) ; else if ( ! stack . length ) ok = false ; else if ( stack . pop ( ) != matching [ ch ] ) ok = false ; if ( ! stack . length ) break ; } else if ( runner . dirty || ! isSpan ( runner ) && ! isBR ( runner ) ) { return { node : runner , status : "dirty" } ; } } return { node : runner , status : runner && ok } ; }
Since parts of the document might not have been properly highlighted, and it is hard to know in advance which part we have to scan, we just try, and when we find dirty nodes we abort, parse them, and re-try.
Since parts of the document might not have been properly highlighted and it is hard to know in advance which part we have to scan we just try and when we find dirty nodes we abort parse them and re - try .