From f606b0641e2c82221e60f88f7e70da129b676436 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 18 Feb 2025 20:49:39 +0100 Subject: [PATCH] workspace: Prevent user from undoing persistent session deserialization (#25106) Closes #21846 Release Notes: - Fixed a bug that made it possible to undo changes in dirty deserialized buffer (with `restore_unsaved_buffers: true`) --- crates/editor/src/items.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 7f40092f0b71ff..f4ea107c439a8e 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()); + } })?; }