From 097cddbd030eb0ba5ed94dfcb707cbb9158df868 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Thu, 5 Nov 2026 03:32:58 +0100 Subject: [PATCH] Resolve and test style changes through Arc::make_mut after the shared-stylesheet change on main Co-Authored-By: Claude Sonnet 5.5 --- crates/docx/tests/it/roundtrip.rs | 2 +- crates/engine/src/cmd/fmt_revisions.rs | 2 +- crates/engine/src/cmd/review/changes.rs | 8 +++++--- crates/engine/src/tests.rs | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/docx/tests/it/roundtrip.rs b/crates/docx/tests/it/roundtrip.rs index 6098a481f6..ad51ae0adb 100644 --- a/crates/docx/tests/it/roundtrip.rs +++ b/crates/docx/tests/it/roundtrip.rs @@ -309,7 +309,7 @@ fn styles_and_lists_round_trip() { fn tracked_style_definition_change_round_trips() { let mut d = Document::new(); d.revisions.push(Revision { kind: RevisionKind::Format, author: "Ana".into(), date: "2026-10-17T10:00:00Z".into(), move_name: None }); - d.styles.upsert(Style { + std::sync::Arc::make_mut(&mut d.styles).upsert(Style { id: "Mine".into(), name: "Mine".into(), kind: StyleKind::Paragraph, diff --git a/crates/engine/src/cmd/fmt_revisions.rs b/crates/engine/src/cmd/fmt_revisions.rs index 3c21e493b8..fc97167be9 100644 --- a/crates/engine/src/cmd/fmt_revisions.rs +++ b/crates/engine/src/cmd/fmt_revisions.rs @@ -242,7 +242,7 @@ pub(crate) fn record(s: &mut Session, id: &str, before: &Document) { r.blocks(&pb.blocks, &mut pa.blocks, 0); } } - r.styles(&before.styles.styles, &mut doc.styles.styles); + r.styles(&before.styles.styles, &mut std::sync::Arc::make_mut(&mut doc.styles).styles); } /// Record the paragraph formatting a command changed on the paragraph at `path` whose text it also diff --git a/crates/engine/src/cmd/review/changes.rs b/crates/engine/src/cmd/review/changes.rs index 3eea0f7b55..e8dd16fe41 100644 --- a/crates/engine/src/cmd/review/changes.rs +++ b/crates/engine/src/cmd/review/changes.rs @@ -101,7 +101,7 @@ fn resolve_styles_sel(s: &mut Session, selected: bool, accept: bool) -> Result CmdResult { fmt_revisions::resolve_containers(&mut part.blocks, accept, 0); } fmt_revisions::resolve_section(&mut s.doc.last_section, accept); - for st in &mut s.doc.styles.styles { - fmt_revisions::resolve_style(st, accept); + if s.doc.styles.styles.iter().any(|st| st.para_change.is_some() || st.chr_change.is_some()) { + for st in &mut std::sync::Arc::make_mut(&mut s.doc.styles).styles { + fmt_revisions::resolve_style(st, accept); + } } // The note separators are block lists of their own, not stories; they must not keep ids of // revisions that are about to be dropped. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 3b5e5bcb55..b82407a820 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3319,7 +3319,7 @@ fn non_property_style_changes_are_not_recorded_as_formatting() { let mut s = s(); run(&mut s, "review.trackChanges", json!({"value": true})); let before = s.doc.clone(); - let st = s.doc.styles.get_mut("Heading1").unwrap(); + let st = std::sync::Arc::make_mut(&mut s.doc.styles).get_mut("Heading1").unwrap(); st.based_on = Some("Title".into()); st.next = Some("Heading2".into()); st.linked = Some("Emphasis".into()); @@ -3363,7 +3363,7 @@ fn tracked_style_change_round_trips_through_docx() { fn rejecting_a_reopened_style_change_keeps_style_metadata() { use wordcraft_doc::styles::{Style, StyleKind, TableStyleParts}; let mut s = s(); - s.doc.styles.upsert(Style { + std::sync::Arc::make_mut(&mut s.doc.styles).upsert(Style { id: "GridX".into(), name: "Grid X".into(), kind: StyleKind::Table,