Hmm, my beforeCursorEnter appears to be firing twice. This below is now currently the entirety of my <script> section (there are no others) and I am getting “myMarker → beforeCursorEnter” printed twice inside the console. Any idea why that is?
I went digging into the source code and it’s inside the source file selection_updates.js, the function skipAtomicInSelection() does make TWO calls to skipAtomic() which calls skipAtomicInner where the calls to signal(m, "beforeCursorEnter") takes place.
The two calls inside the skipAtomicInSelection() are to set variables newAnchor and newHead
Should I use a debounce method to deal with the double “beforeCursorEnter” events or is there a better way?
Looks like it fires it both for the selection head and the selection anchor, even if those are the same. The patch below avoids the extra call, though you’d probably still want to make your handler idempotent or debounce it somehow, since quick selection changes or the creation of a non-cursor selection in your range will still cause it to fire multiple times.