Skip to content

Commit

Permalink
workspace: Prevent user from undoing persistent session deserializati…
Browse files Browse the repository at this point in the history
…on (zed-industries#25106)

Closes zed-industries#21846

Release Notes:

- Fixed a bug that made it possible to undo changes in dirty
deserialized buffer (with `restore_unsaved_buffers: true`)
  • Loading branch information
osiewicz committed Feb 19, 2025
1 parent f69965d commit c06fddd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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());
}
})?;
}

Expand Down

0 comments on commit c06fddd

Please sign in to comment.