From b141bc335fa1d843ffcc6bf7b95b403fe7796fb3 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 13 Oct 2026 20:46:27 +0000 Subject: [PATCH] Integration: renaming or deleting a paragraph style also updates the table of contents' entry and title styles (#755) --- crates/engine/src/cmd/style.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/style.rs b/crates/engine/src/cmd/style.rs index 583338ad5..06f51edf7 100644 --- a/crates/engine/src/cmd/style.rs +++ b/crates/engine/src/cmd/style.rs @@ -655,6 +655,12 @@ fn rename_style(d: &mut designcraft_doc::Document, para: bool, from: &str, to: & let (fo, eo) = (&mut d.footnote_options, &mut d.endnote_options); [&mut fo.para_style, &mut eo.para_style, &mut eo.heading_style].into_iter().for_each(rename); d.toc.iter_mut().flat_map(|t| t.entries.iter_mut().map(|e| &mut e.style)).for_each(rename); + for t in d.toc.iter_mut() { + let formats = t.entries.iter_mut().map(|e| &mut e.entry_style).chain([&mut t.title_style]); + for r in formats.filter(|r| r.as_deref() == Some(from)) { + *r = Some(to.to_string()); + } + } } else { for s in &mut st.character { if s.name == from { @@ -2461,9 +2467,9 @@ mod delete_tests { d.toc = Some(Toc { story, title: "Contents".into(), - entries: vec![TocEntry::new("Table Body", 1)], + entries: vec![TocEntry { entry_style: Some("Table Body".into()), ..TocEntry::new("Table Body", 1) }], page_numbers: false, - title_style: None, + title_style: Some("Table Body".into()), }); Ok(()) })