small fix for syntax highlighter in async mode #83

Merged
merged 1 commit into from Jan 11, 2013

Conversation

Projects
None yet
2 participants

yiding commented Jan 11, 2013

when highlighting finishes in a different thread, the source code may
have changed in the mean time, making the tokenization invalid. This can
cause coloring to be applied that's off by a few characters, or even
exceptions if the file has been shortened.

This fix discards the tokenizer result if the file has changed by seeing
if there is another queued highlighter job. When continuously typing, newly
typed characters may not highlight immediately. But on the other hand, this
actually makes the async-highlight mode usable for me.

Also use the implicit lock in the SingleJobQueue object for
synchronization instead of creating another object.

@yiding yiding fix issues when running highlighter in a different thread
when highlighting finishes in a different thread, the source code may
have changed in the mean time, making the tokenization invalid. This can
cause coloring to be applied that's off by a few characters, or even
exceptions if the file has been shortened.

This fix discards the tokenizer result if the file has changed by seeing
if there is another queued highlighter job. This has a side effect of
causing newly typed text to syntax highlight slower (if you type really
fast, or highlighting is slow).

Also use the implicit lock in the SingleJobQueue object for
synchronization instead of creating another object.
8deb3ac

@JPMoresmau JPMoresmau added a commit that referenced this pull request Jan 11, 2013

@JPMoresmau JPMoresmau Merge pull request #83 from yiding/master
small fix for syntax highlighter in async mode
3e6bd3d

@JPMoresmau JPMoresmau merged commit 3e6bd3d into JPMoresmau:master Jan 11, 2013

Owner

JPMoresmau commented Jan 11, 2013

Thank you, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment