Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge transactions into the original assistant transaction

Antonio Scandurra301a12923f5d
diff --git a/crates/ai/src/refactor.rs b/crates/ai/src/refactor.rs
index 1eb54d93738..f668f8d5ac4 100644
--- a/crates/ai/src/refactor.rs
+++ b/crates/ai/src/refactor.rs
@@ -85,7 +85,7 @@ impl RefactoringAssistant {
anyhow::Ok(())
});
- let mut last_transaction = None;
+ let mut first_transaction = None;
while let Some(hunks) = hunks_rx.next().await {
editor.update(&mut cx, |editor, cx| {
let mut highlights = Vec::new();
@@ -120,14 +120,15 @@ impl RefactoringAssistant {
cx,
);
if let Some(transaction) = buffer.end_transaction(cx) {
- if let Some(last_transaction) = last_transaction {
+ if let Some(first_transaction) = first_transaction {
buffer.merge_transaction_into(
- last_transaction,
transaction,
+ first_transaction,
cx,
);
+ } else {
+ first_transaction = Some(transaction);
}
- last_transaction = Some(transaction);
buffer.finalize_last_transaction(cx);
}
});