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.

workspace: Prevent user from undoing persistent session deserialization (#25106)

Piotr Osiewiczf606b0641e2c
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs
index 7f40092f0b7..f4ea107c439 100644
--- a/crates/editor/src/items.rs
+++ b/crates/editor/src/items.rs
@@ -1073,6 +1073,9 @@ impl SerializableItem for Editor {
buffer.set_language(Some(language), cx);
}
buffer.set_text(contents, cx);
+ if let Some(entry) = buffer.peek_undo_stack() {
+ buffer.forget_transaction(entry.transaction_id());
+ }
})?;
cx.update(|window, cx| {
@@ -1127,6 +1130,9 @@ impl SerializableItem for Editor {
);
}
buffer.set_text(buffer_text, cx);
+ if let Some(entry) = buffer.peek_undo_stack() {
+ buffer.forget_transaction(entry.transaction_id());
+ }
})?;
}