Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Update to latest CodeMirror #4234

Merged
merged 1 commit into from
Jun 14, 2013
Merged

Update to latest CodeMirror #4234

merged 1 commit into from
Jun 14, 2013

Conversation

njx
Copy link
Contributor

@njx njx commented Jun 14, 2013

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.

* 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)
@njx
Copy link
Contributor Author

njx commented Jun 14, 2013

(Just to clarify--the reason for the fix for #2335 is that it was also breaking our unit test for that case due to the increased delay. Rather than just increasing the hard-coded delay in the unit test further :), it seemed better to actually fix the problem.)

@ghost ghost assigned gruehle Jun 14, 2013
@njx
Copy link
Contributor Author

njx commented Jun 14, 2013

To @gruehle

@njx
Copy link
Contributor Author

njx commented Jun 14, 2013

FYI: ran all the unit tests, and all passed except Live Development (which has been intermittently failing for me anyway). I did some spot checks of inline editors to make sure they're still working.

@gruehle
Copy link
Member

gruehle commented Jun 14, 2013

The longer delay is definitely noticeable when opening or closing a block comment. We may want to push back on the 400ms delay to make it something smaller.

Other than that, everything seems to be working fine, and I verified that #2335 is fixed.

Merging.

gruehle added a commit that referenced this pull request Jun 14, 2013
Update to latest CodeMirror
@gruehle gruehle merged commit 10f4054 into master Jun 14, 2013
@gruehle gruehle deleted the nj/update-cm branch June 14, 2013 21:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants