I am writing a new Language mode. I have managed to mark certain tokens as “error” when they are undefined variables, and this works well. However, while typing out one of these tokens, it will be marked as “error” until completely typed out. Naturally, the styling used for “error” is quite eye-catching and unpleasant (as it should be), but this makes typing very annoying, even when typing correctly.
To solve this, I would like to know if it is possible to account for current cursor position in a codemirror mode, somehow. Either as a function that returns coords, or perhaps as an attribute on the stream object, or even as a pseudo whitespace token that can be recognised. In any case, identifying where the token is would allow me to distinguish between incorrect tokens that are still being written, and incorrect tokens which are not.
Another potential solution might be simply to detect which tokens were last updated by the user.
Thanks for any help!