I've almost got a fully working syntax highlighting lexer. However, I've run into a problem I don't know how to solve. Sometimes, when editing the middle of a file (that is being highlighted by my lexer) I get:
[ 273853] ERROR - pi.editor.ex.util.SegmentArray - Error shifting segments: myStarts = -1, myEnds = 4
Per: (https://github.com/ceylon/ceylon-ide-intellij/issues/6) this seems to be an issue with incremental invocation.
In particular I've noticed this happens when changing an item from a keyword to not a keyword. That is, if I edit a 'for' statement in the middle of a file, to say 'fo' or 'fora', the change from a keyword, to not a keyword seems to irritate the intelliJ syntax highlight engine. If I change a quotation, this doesn't happen, I presume because editing the middle of a quotation doesn't change the underlying token type (since it's still a quotation).
How do I force the syntax highlighter to recognize that the token type has been changed, and it shouldn't just try to 'shift' it?