Are there any builtin affordances for making decorations behave atomically (in which selection treats the replaced range as a single position) like there was for CM5’s atomic
TextMarker
option?
If not, do you have any tips on rolling my own? My current solution is to install an EditorView update listener that:
- runs through all the selection ranges
- uses
DecorationSet.between()
to intersect with relevant decorations - Creates a new transaction to move that range of the selection.
Unfortunately, this is surprisingly complicated. When the cursor enters the range from the left, it needs to leave to the right and vice versa. Unless I’m missing something, there isn’t any builtin way to determine the direction of motion from the view update, so I’m iterating through every range of the new selection, hoping the range with the same index in the old state’s selection is the appropriate one to compare to, and then comparing heads.
Getting the interactions correct for every combination of (enters from left | enters from right | enters via click) X (point cursor | selection) X (multiple ranges) seems both fiddly and generic (to my untrained eye).
Does it seem like a good candidate for future inclusion upstream?