Thanks @mauricio.szabo, I think it’s a no-go though. It doesn’t seem like you can make changes to a TextEditor in response to changes to the same TextEditor.
It is a programming error to invoke [edit] from within a text change callback (such as one registered using onDidChange()). Attempting to do so will throw an Error.
Ideally, I guess there would be a onWillChange
listener so that it would be possible to hijack an edit mid-flight and modify it before it lands on the undo stack.
But on the other hand I’ve discovered parinfer-plus
, and it does seem like it handles itself better than parinfer
in Atom! I’m particularly noticing fewer surprises when copying and pasting.