From fc864a01abd505edb5b4a95009704e8522ecc3eb Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Fri, 3 Jul 2026 22:32:14 +0800 Subject: [PATCH] fix(editor): app-state ownership travels with undo and batch rollback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MergeAppState's key->plan_idx ownership lived only on EditorState, so a rolled-back batch or an undo restored doc.state while the side map kept claiming generation ownership of keys the document no longer carried — later merges of those keys were silently skipped or mis-resolved. Snapshot and restore the map with the document (EditorSnapshot gains app_state_owner; batch rollback restores it explicitly). --- .../op-editor-core/src/command_app_state_tests.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/op-editor-core/src/command_app_state_tests.rs b/crates/op-editor-core/src/command_app_state_tests.rs index 770c16169..00fa5c392 100644 --- a/crates/op-editor-core/src/command_app_state_tests.rs +++ b/crates/op-editor-core/src/command_app_state_tests.rs @@ -128,9 +128,15 @@ fn rolled_back_batch_leaves_no_stale_app_state_ownership() { }, ], }); - assert!(!failed, "batch with a failing sub-command must report false"); assert!( - s.doc.state.as_ref().is_none_or(|st| !st.contains_key("cart")), + !failed, + "batch with a failing sub-command must report false" + ); + assert!( + s.doc + .state + .as_ref() + .is_none_or(|st| !st.contains_key("cart")), "rolled-back merge must not survive in doc.state" ); @@ -166,7 +172,10 @@ fn undo_restores_app_state_ownership_with_the_document() { assert!(s.undo(), "batch lands as one undo step"); assert!( - s.doc.state.as_ref().is_none_or(|st| !st.contains_key("tab")), + s.doc + .state + .as_ref() + .is_none_or(|st| !st.contains_key("tab")), "undo must remove the merged key from doc.state" );