mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 02:47:34 +03:00
Clear multi-buffer redo stack when pushing transaction onto undo stack
This commit is contained in:
parent
03dc7c8eb0
commit
37ca06df53
@ -2479,6 +2479,7 @@ impl History {
|
||||
self.undo_stack.pop();
|
||||
false
|
||||
} else {
|
||||
self.redo_stack.clear();
|
||||
let transaction = self.undo_stack.last_mut().unwrap();
|
||||
transaction.last_edit_at = now;
|
||||
for (buffer_id, transaction_id) in buffer_transactions {
|
||||
@ -2511,6 +2512,7 @@ impl History {
|
||||
};
|
||||
if !transaction.buffer_transactions.is_empty() {
|
||||
self.undo_stack.push(transaction);
|
||||
self.redo_stack.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3935,6 +3937,16 @@ mod tests {
|
||||
buffer_1.update(cx, |buffer_1, cx| buffer_1.redo(cx));
|
||||
assert_eq!(multibuffer.read(cx).text(), "ABCD1234\nAB5678");
|
||||
|
||||
// Redo stack gets cleared after an edit.
|
||||
now += 2 * group_interval;
|
||||
multibuffer.start_transaction_at(now, cx);
|
||||
multibuffer.edit([(0..0, "X")], cx);
|
||||
multibuffer.end_transaction_at(now, cx);
|
||||
assert_eq!(multibuffer.read(cx).text(), "XABCD1234\nAB5678");
|
||||
multibuffer.redo(cx);
|
||||
assert_eq!(multibuffer.read(cx).text(), "XABCD1234\nAB5678");
|
||||
multibuffer.undo(cx);
|
||||
assert_eq!(multibuffer.read(cx).text(), "ABCD1234\nAB5678");
|
||||
multibuffer.undo(cx);
|
||||
assert_eq!(multibuffer.read(cx).text(), "1234\n5678");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user