Fix bugs with applying hunks from branch buffers (#18721)

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
Max Brunsfeld 2024-10-07 16:28:33 -07:00 committed by GitHub
parent 3c91184726
commit b0a16a7601
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 128 additions and 61 deletions

View file

@ -1430,16 +1430,22 @@ impl Buffer {
counts.insert(edit_id, self.undo_map.undo_count(edit_id) + 1);
}
let operation = self.undo_operations(counts);
self.history.push(operation.clone());
operation
}
pub fn undo_operations(&mut self, counts: HashMap<clock::Lamport, u32>) -> Operation {
let timestamp = self.lamport_clock.tick();
let version = self.version();
self.snapshot.version.observe(timestamp);
let undo = UndoOperation {
timestamp: self.lamport_clock.tick(),
version: self.version(),
timestamp,
version,
counts,
};
self.apply_undo(&undo);
self.snapshot.version.observe(undo.timestamp);
let operation = Operation::Undo(undo);
self.history.push(operation.clone());
operation
Operation::Undo(undo)
}
pub fn push_transaction(&mut self, transaction: Transaction, now: Instant) {