adobe/brackets — pull request #4234 by njx (2013-06-14 18:31:48+00:00)
Title: Update to latest CodeMirror

* Explicitly call `markClean()` after `clearHistory()` since the two are no longer tied
* Pass new "precise" parameter to getTokenAt() to ensure tokens are properly updated after edits (addresses #2335)

More detail on the latter: The reason for #2335 was that the highlight worker doesn't kick in after an update until after a certain delay. This was exacerbated by a recent commit to CodeMirror that increases the delay. We submitted a patch to CodeMirror that adds a "precise" parameter, which ensures that when `getTokenAt()` is called, it ignores cached line states that haven't been refreshed yet during the current highlighting pass.

Note that this doesn't absolutely guarantee precision, since `getTokenAt()` will look backwards a maximum of 100 lines to find a line with a known good state; if it doesn't find one, it will pick the line with the least indentation and assume that it can use the mode's default start state at the beginning of that line. But it should be a good enough heuristic.

Also note that passing true for this parameter to `getTokenAt()` means that it will scan backward for a good line state farther than it originally did when run immediately after an edit. I think that performance tradeoff is fine for increased accuracy, and in most cases (like typing) it won't affect us that much because the last edit is on the current line.