replaceSelections generates multiple change events

I’d like to replace delete ranges in a single operation, without generating multiple change events.

Right now, I’m using replaceSelections(selections, replacements), where selections is a proper array of anchor * head pairs and replacements is an array of the same length containing only the empty string. This works as expected…except CM generates a change event for each range being replaced.

Is this a bug, or am I using the API incorrectly?

Neither—this is how the library works. You might be interested in the changes event instead.

Ah, so there’s no way to prevent CM from registering a change event for each one? My code does a pretty hefty amount of work on each change. It sounds like I should be using the changes event then, instead of the change event…

Thanks, as always, Marijn!