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`)
This commit is contained in:
Piotr Osiewicz 2025-02-18 20:49:39 +01:00 committed by GitHub
parent e5d8bd27da
commit f606b0641e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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());
}
})?;
}