From fb33f78269c06fad868f0d9ebb61347ff63dc358 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 7 Nov 2026 08:17:37 +0700 Subject: [PATCH] Text styles: a style with no paragraph values keeps a bulleted text linked --- crates/engine/src/cmd/styles.rs | 7 ++++++- crates/engine/src/styles_behaviour_tests.rs | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/styles.rs b/crates/engine/src/cmd/styles.rs index ff7838108..61f2c265f 100644 --- a/crates/engine/src/cmd/styles.rs +++ b/crates/engine/src/cmd/styles.rs @@ -782,7 +782,12 @@ pub fn sync_text_styles(doc: &mut Document, ids: &[NodeId]) { let gone: Vec<(usize, usize)> = t2 .spans() .iter() - .filter(|(a, b, s)| s.style_id.as_deref().is_some_and(|sid| paras.get(sid).is_none_or(|ps| !t2.shows_paragraph_style_in(*a, *b, ps)))) + .filter(|(a, b, s)| { + // A style with no paragraph values (every style in older files) asks nothing of them. + s.style_id + .as_deref() + .is_some_and(|sid| paras.get(sid).is_none_or(|ps| **ps != ParagraphStyle::default() && !t2.shows_paragraph_style_in(*a, *b, ps))) + }) .map(|(a, b, _)| (*a, *b)) .collect(); for (a, b) in gone { diff --git a/crates/engine/src/styles_behaviour_tests.rs b/crates/engine/src/styles_behaviour_tests.rs index f1ebd96de..73fe1edef 100644 --- a/crates/engine/src/styles_behaviour_tests.rs +++ b/crates/engine/src/styles_behaviour_tests.rs @@ -473,3 +473,21 @@ fn descriptions_and_library_styles() { run(&mut s, "style.update", json!({"style": st, "description": "Body text"})); assert_eq!(s.doc().unwrap().style(&st).unwrap().description, "Body text"); } + +#[test] +fn a_style_without_paragraph_values_keeps_a_bulleted_text_linked() { + // Styles from older files set no paragraph values, so a list or spacing on their text isn't + // an edit of the style: it stays linked (docs silent, pinned to how such files worked). + let mut s = Session::new(); + let t = text(&mut s, 0.0); + run( + &mut s, + "node.set", + json!({"id": t, "props": {"characters": "A +B"}}), + ); + let st = sid(run(&mut s, "style.create", json!({"type": "text", "name": "Plain", "value": {"fontSize": 11}}))); + run(&mut s, "style.apply", json!({"ids": [t], "style": st})); + run(&mut s, "node.set", json!({"id": t, "props": {"listStyle": "bulleted", "paragraphSpacing": 6}})); + assert_eq!(node(&s, t).styles.text.as_deref(), Some(st.as_str())); +}