godot
godot copied to clipboard
Undo/Redo symmetry easily breaks when making edits from inspector
Tested versions
Reproducible in 4.1, 4.2, 4.3
System information
Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 32.0.15.6109) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 Threads)
Issue description
When making edits, even with only one scene open (without conflicting global edits arising from having multiple scenes open), it is easy to break the symmetry of undo/redo if you make edits touch any global resources (e.g. editing a material from a material slot in the inspector). This leads to very frustrating situations where changes you thought you already wiped out (with undos and new operations) make a reappearance and don't go away. You have to either manually neutralize the unwanted changes, or go back all the way before the unwanted changes were made and recreate your desired changes. That is the best case. In the worst case, these re-emerging changes are undetected and saved, causing mysterious bugs.
Case 1: When undoing a change scene, it can skip a global change (does not undo it), but not skip it when redoing, leading to an asymmetry. The same thing can happen if you undo a global change that is preceded by a scene change, in which case the scene change can get skipped.
https://github.com/user-attachments/assets/c8f0549c-2253-4344-9b4e-2c16f4be8ace
Case 2: When performing operations that "reset" the history stack, it only resets either the scene stack, or the global stack depending on what scope the operation is in. Because the other stack is left alone, the history cursor skips ahead of any entries in the other stack, leaving "remnants" of edits that were performed before an intended history reset.
https://github.com/user-attachments/assets/74cb083d-0dcc-4d90-bb6d-b059d05c6440
Expected Behaviour The expected behaviour is that when undo/redo are used when a scene is open, it steps back/forward by exactly one entry in the history panel, in a manner that:
- Accurately retraces the user's operation history
- Is symmetrical in either direction of history traversal It is worth noting that this expected behaviour is what happens when navigating the history manually via clicking in the history panel. The issues described only occur when performing undo/redo actions.
Relevant Links Proposal for separate undo histories Pull request for separate undo histories
Steps to reproduce
Make sure to have the history panel open for clearer feedback during the repro.
Repro for Case 1:
- Open
test.tscnin the attached project - Select the sphere
- Edit its albedo color from the inspector
- Undo
- Move the sphere
- Undo
- Redo
- Observe that the redo operation alters the color of the sphere, instead of moving the sphere
Repro for Case 2:
- Open
test.tscnin the attached project - Select the sphere
- Move the sphere
- Edit its albedo color from the inspector
- Undo
- Move the sphere again
- Observe that the second move operation skips past the color edit, leaving it in the history stack