Currently running Python text editor operators in edit-mode uses the edit-mode undo system, instead of the text editor's undo.
This causes issues using Python operators in edit-mode, see: T80611
Possible solutions:
- Always use the text editor's undo stack when running operators in the text editor.
Doing this automatically is complicated by the need to initialize the undo state before edits are made.
- Automatically use the text-editors's undo stack when it's modified.
implementation is likely to be messy/involved.
- Expose text editor undo begin/end to Python (ideally as a context manager).
It would be nice to avoid manually dealing with the undo stack, noting this since it's one of the most straightforward solutions.