Is it possible to get the undo redo of the Godot script editor?
I am currently inserting text into the sceipt editor via code and that triggers the undo redo to record it. So when the user presses Ctrl-Z, it goes back to what I inserted with code.
So essentially, I want to be able to remove some undo steps (because I clear the code-edited bit anyway, it’s just a preview).
TLDR: I want to edit the text of the script editor without affecting its undo redo state.
I found a fix! You can use the TextEdit.begin_complex_operation() and TextEdit.end_complex_operation() methods to combine multiple actions into one!
Try to stay away from TextEdit.start_action() and TextEdit.end_action(), as they both depend on a timer which determines when an “action” is done, which is three seconds by default.
So yeah, I call begin_complex_operation() at the begin, then I can edit the text however I want and for as many seconds as I want.
Then finally, when I wrapped up with the edits, I call end_complex_operation() and the UndoRedo of the script editor accepts that as one action.