Undo subsequent edits when undoing in multi-buffer
When undoing in the multi-buffer, don't preserve edits that occurred outside the multi-buffer after the edit being undone. Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
d1f1563278
commit
9936bb2efa
3 changed files with 54 additions and 42 deletions
|
@ -1695,7 +1695,7 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn undo_transaction(
|
||||
pub fn undo_to_transaction(
|
||||
&mut self,
|
||||
transaction_id: TransactionId,
|
||||
cx: &mut ModelContext<Self>,
|
||||
|
@ -1703,13 +1703,15 @@ impl Buffer {
|
|||
let was_dirty = self.is_dirty();
|
||||
let old_version = self.version.clone();
|
||||
|
||||
if let Some(operation) = self.text.undo_transaction(transaction_id) {
|
||||
let operations = self.text.undo_to_transaction(transaction_id);
|
||||
let undone = !operations.is_empty();
|
||||
for operation in operations {
|
||||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if undone {
|
||||
self.did_edit(&old_version, was_dirty, cx)
|
||||
}
|
||||
undone
|
||||
}
|
||||
|
||||
pub fn redo(&mut self, cx: &mut ModelContext<Self>) -> Option<TransactionId> {
|
||||
|
@ -1725,7 +1727,7 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn redo_transaction(
|
||||
pub fn redo_to_transaction(
|
||||
&mut self,
|
||||
transaction_id: TransactionId,
|
||||
cx: &mut ModelContext<Self>,
|
||||
|
@ -1733,13 +1735,15 @@ impl Buffer {
|
|||
let was_dirty = self.is_dirty();
|
||||
let old_version = self.version.clone();
|
||||
|
||||
if let Some(operation) = self.text.redo_transaction(transaction_id) {
|
||||
let operations = self.text.redo_to_transaction(transaction_id);
|
||||
let redone = !operations.is_empty();
|
||||
for operation in operations {
|
||||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
self.did_edit(&old_version, was_dirty, cx);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if redone {
|
||||
self.did_edit(&old_version, was_dirty, cx)
|
||||
}
|
||||
redone
|
||||
}
|
||||
|
||||
pub fn completion_triggers(&self) -> &[String] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue