Clear redo stack when pushing remote transaction or ending a local one
This commit is contained in:
parent
5f69996604
commit
03dc7c8eb0
2 changed files with 12 additions and 0 deletions
|
@ -529,6 +529,16 @@ fn test_history() {
|
||||||
assert!(buffer.end_transaction_at(now).is_none());
|
assert!(buffer.end_transaction_at(now).is_none());
|
||||||
buffer.undo();
|
buffer.undo();
|
||||||
assert_eq!(buffer.text(), "12cde6");
|
assert_eq!(buffer.text(), "12cde6");
|
||||||
|
|
||||||
|
// Redo stack gets cleared after performing an edit.
|
||||||
|
buffer.edit([(0..0, "X")]);
|
||||||
|
assert_eq!(buffer.text(), "X12cde6");
|
||||||
|
buffer.redo();
|
||||||
|
assert_eq!(buffer.text(), "X12cde6");
|
||||||
|
buffer.undo();
|
||||||
|
assert_eq!(buffer.text(), "12cde6");
|
||||||
|
buffer.undo();
|
||||||
|
assert_eq!(buffer.text(), "123456");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -216,6 +216,7 @@ impl History {
|
||||||
self.undo_stack.pop();
|
self.undo_stack.pop();
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
self.redo_stack.clear();
|
||||||
let entry = self.undo_stack.last_mut().unwrap();
|
let entry = self.undo_stack.last_mut().unwrap();
|
||||||
entry.last_edit_at = now;
|
entry.last_edit_at = now;
|
||||||
Some(entry)
|
Some(entry)
|
||||||
|
@ -276,6 +277,7 @@ impl History {
|
||||||
last_edit_at: now,
|
last_edit_at: now,
|
||||||
suppress_grouping: false,
|
suppress_grouping: false,
|
||||||
});
|
});
|
||||||
|
self.redo_stack.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_undo(&mut self, op_id: clock::Local) {
|
fn push_undo(&mut self, op_id: clock::Local) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue