mode token - detecting the token in the current cursor position

I have a mode token function that implements spellchecking - it checks to see if the token is in a dictionary and highlights it otherwise.

I want to prevent tokens being detected as typos while they are being typed, that is, I want to skip the token under the cursor position.

What is the best way to achieve that ?

One hurdle I see is that in the token function I don’t seem to have access to the CM instance and so cannot call getCursor() to detect the current position.

Any help ? thx!

Modes are designed to return situation-independent syntax info. One way to approach this would be to have a separate piece of code, called from a cursorActivity event handler, add a class to the word in front the cursor that suppresses the mode’s highlighting.