Closed porky11 closed 1 year ago
In the example you can see the removed character being stored in the command.
This line: self.0 = s.pop().ok_or("s is empty")?;
stores the removed character in self.0
.
What if someone has an action enum with two variants: The Add
from the example, and one that deletes n characters starting at a given offset? Should the action store the removed characters when apply
is called so it can put them back if undo
is later invoked?
@TedDriggs Yes that is what I would do
In the examples, undo always just removes the last symbol from the string.
When I also have a
Remove
action, I would need to store, which letter has been removed in order to undo that action.I didn't find anything about that in the documentation. It has to be possible already. Else this crate wouldn't be very useful.