It seems inserts between a previous commit and a call to clear don't get managed properly, as they appear permanently within the container after an undo.
The following code:
use std::collections::BTreeMap;
use undoredo::Recorder;
use undoredo::UndoRedo;
use undoredo::aliases::BTreeMapDelta;
let mut recorder: Recorder<BTreeMap<usize, char>> = Recorder::new(BTreeMap::new());
let mut undoredo: UndoRedo<BTreeMapDelta<usize, char>> = UndoRedo::new();
recorder.insert(1, 'X');
undoredo.commit(&mut recorder);
println!("a: {:?}", recorder.container());
recorder.insert(2, 'Y');
recorder.clear();
undoredo.commit(&mut recorder);
println!("b: {:?}", recorder.container());
undoredo.undo(&mut recorder);
println!("c: {:?}", recorder.container());
undoredo.redo(&mut recorder);
println!("d: {:?}", recorder.container());
produces this output:
a: {1: 'X'}
b: {}
c: {1: 'X', 2: 'Y'}
d: {2: 'Y'}
I would expect a and c to be equivalent, as well as b and d. In particular, the 2: 'Y' entry should disappear permanently as it was never actually committed. Yet it stays even after a call to redo.
It seems inserts between a previous commit and a call to
cleardon't get managed properly, as they appear permanently within the container after an undo.The following code:
produces this output:
I would expect
aandcto be equivalent, as well asbandd. In particular, the2: 'Y'entry should disappear permanently as it was never actually committed. Yet it stays even after a call toredo.