owickstrom / komposition

The video editor built for screencasters
https://owickstrom.github.io/komposition/
Mozilla Public License 2.0
428 stars 22 forks source link

Optimize undo/redo history #82

Closed owickstrom closed 5 years ago

owickstrom commented 5 years ago

Description:

This pull requests fixes problems with the naive implementation of undo/redo that was used before. Instead of storing all the previous (and possibly future/redo states), it now only stores the actions. When they are run they also return the inverse of themselves, such they can be undone. A redo is therefore an undo of an undo.

The undo/redo behaviour is slightly different, in that it discards any redos when the history "diverges", i.e. when the user performs new actions to add to the undo history.

Another change is the addition of explicit tracks. These can now be focused in the UI. Documentation coming up!

This PR changes the project data structures and also the binary format. It's not compatible with old stored projects. (This is something that should be addressed separately, soon!)

For testing, property-based tests for undo/redo were added before this change, and held up during the entire refactoring with very small tweaks. There are also some example-based tests added.

Checklist:

Please make sure to check the following items (that are applicable.)