Expose startOperation and endOperation?


Hello, CodeMirror!

I wanted to check here whether a PR would be accepted to export the startOperation and endOperation methods on CodeMirror instances. I know about the option to call operation(callback), but sometimes I have groups of editor changes that happen with short timeouts, or in the same stack but in some way that I can’t “capture” all the parts in a callback. (This happens, for example, in React applications, where multiple child components make changes to the editor in a single render cycle, but application code can’t wrap the rendering of a subtree because of inversion of control.

If CodeMirror would accept such a PR (or some other way to allow asynchronous operations that only redraw at the end), I’d be very happy to be the one to write it up.




I don’t think there’s a deep reason not to allow this, I just haven’t so far because it seems rather error-prone and usually not something people need. I’m a little bit grossed out by a data flow where multiple components are mutating an editor, instead of the data that determines the editor’s state being computed in one go, but yeah, so it goes sometimes. If you create a PR for this, including docs that explicitly explain that you probably don’t need those methods, I think I’d be okay with it.