Updating multiple selections individually with a transaction

Hi there,

I’m pretty new to Codemirror6
I’m trying to apply a transaction to my document which has multiple selections
For each selection, I’d like to detect if the range’s from === the range’s to
In that case I’d need to change the cursor position in the final document but always with this transaction

What I’m doing is

changes.push({from: ..., to: ..., insert: replacementText});

Then I have an Array of changes and I dispatch it by

.dispatch({changes: changes});

Which works fine
But for some edge cases I need to update the selection in one go with the transaction
My edge case is, that when there’s just the cursor (selection-start === selection-end) then I’d need the selection to “jump” further to the right in the final document for a given value

Does anybody have an example or an idea how that can be done?

I appreciate your answers
Best wishes,

Have you seen state.changeByRange? That is written for pretty much this kind of use case.

Thank you @marijn , I managed to achieve what I wanted using state.changeByRange !

Thanks again,