In a code editor use case, the user typically does not "format" the richt text, but the system is creating all the decorations base on the current text, e.g. syntax highlighting.
With the current solution all changes in syntax highlighting will be visible to the user in the und/redo stack. This should not be the case. Maybe an API to filter the things going into undo/redo stack maybe a good option to give back control over this process to the application using RTA.