Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for option to getTokenAt()/getStateBefore() to improve precision after edits #1610

Closed
wants to merge 1 commit into from
Closed

Suggestion for option to getTokenAt()/getStateBefore() to improve precision after edits #1610

wants to merge 1 commit into from

Conversation

njx
Copy link
Contributor

@njx njx commented Jun 13, 2013

Because re-highlighting is delayed after an edit, the cached mode state for lines after doc.frontier can be invalid. This proposal adds a precise option to getTokenAt() and getStateBefore() that makes them ignore line states after the frontier when trying to find the first valid line.

This doesn't guarantee total accuracy since it will still cut off the search at 100 lines, but it will be at least as accurate as the case where no highlighting had previously been run. (And, in most cases, the thing we're trying to get the token for will be near the last edit point, so it will usually hit the frontier.)

I'm open to other approaches to dealing with this issue, but this seemed the least invasive to me.

@marijnh
Copy link
Member

marijnh commented Jun 14, 2013

This sounds okay. It's a bit obscure, interface-wise, but I guess it isn't likely to trip people up. Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants