What is the intended mechanism to tie event handlers back to specific bits of content?

I have a concept question. If I have a bunch of SyntaxNode references held in a ViewPlugin, I don’t see what the intent is to know when various text offsets go stale? Right now I just recreate all my widgets every time anything changes, but obviously anything asynchronous (UI interaction, long running requests) come back and the offsets are wrong. No surprise there… but short of just embedded some sort of unique tags or paragraph IDs everywhere and searching for them to find my locations again, is there some mechanism I was supposed to use to help me “slide around” my references while the user is typing above them? Yes I could write something that tracks changes to the document and adjust any of my references “below” that accordingly, but it would still be wrong unless all “change” notifications are synchronous.

My conclusion so far is that yes I am supposed to reuse decorations for things like syntax highlighting or showing some UI (don’t build new DOM), but the event handlers for any of those things really can’t reliably hold SyntaxNode and have to basically run like a script of “find text matching this and that, and change it” when the interaction happens.

Posting this here in case there is a mechanism I was supposed to use that lets you put some sort of anchors on the content (in memory only, without saving IDs into the actual text) to find undisturbed lines in the document again in a new view state.

Follow up: I wrote a very over-engineered state field extension that stores text ranges of interest and updates them as the document changes. This doesn’t seem like a good solution, relying on every plugin to do this separately (also it is complicated.)