Excluding changes of a certain origin from the undo history

I’m using replaceRange() to update some editor values in the background.
As the user should be oblivious to these updates, I’d like to exclude them from the editor’s undo history.
I’m hoping to find a more supported alternative than manipulating the JSON data returned by getHistory() directly; in which I can’t quite differentiate between changes of different origins and I’m not clear on the relation between Object changes and Selection changes. (should just all changes till and including the last Object change be popped?)
Is there a way to accomplish this natively by CM?


The undo history is built in such a way that it can only revert changes if the document is exactly what it was when the change was made. Thus, omitting changes from the history does not work (and filtering them out through getHistory/setHistory is likely to corrupt your document when changes are undone near ignored changes.

Thanks Marijn.
I’ll try to work around this.

You’ve probably solved this, but if not, you may be able to fold your changes into an existing undo group, so that the changes get undone along with whatever the person was doing, thus staying invisible. Something to do with using the ‘+’ symbol with the ‘origin’ property perhaps (like the stuff described for selections - http://codemirror.net/doc/manual.html#selection_origin).