diff --git a/crates/engine/src/cmd/threads/tests.rs b/crates/engine/src/cmd/threads/tests.rs index 9d56ca0c9..601ba00ff 100644 --- a/crates/engine/src/cmd/threads/tests.rs +++ b/crates/engine/src/cmd/threads/tests.rs @@ -20,6 +20,25 @@ fn text(s: &Session, id: u64) -> String { } } +#[test] +fn empty_later_frames_keep_the_first_frames_edited_paragraph_style() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 300})).unwrap(); + let a = + s.execute("text.create", &json!({"x": 10, "y": 10, "text": "First", "area": {"width": 150, "height": 60}})).unwrap()["id"].as_u64().unwrap(); + let b = s.execute("shape.rectangle", &json!({"x": 200, "y": 10, "width": 150, "height": 60})).unwrap()["id"].as_u64().unwrap(); + let c = s.execute("shape.rectangle", &json!({"x": 400, "y": 10, "width": 150, "height": 60})).unwrap()["id"].as_u64().unwrap(); + s.execute("select.set", &json!({"ids": [a, b, c]})).unwrap(); + s.execute("text.thread.create", &json!({})).unwrap(); + assert_eq!([text(&s, a), text(&s, b), text(&s, c)], ["First", "", ""]); + s.execute("text.setFormat", &json!({"ids": [a], "hyphenate": true})).unwrap(); + let hyphenates = |id| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind { + NodeKind::Text(t) => t.para_at(0).hyphenate, + _ => panic!("not text"), + }; + assert_eq!([hyphenates(a), hyphenates(b), hyphenates(c)], [true, true, true]); +} + #[test] fn thread_flows_reflows_on_edit_and_survives_delete() { let (mut s, a, b) = setup(); diff --git a/crates/text/src/thread.rs b/crates/text/src/thread.rs index 27c6a2e70..aacc78b23 100644 --- a/crates/text/src/thread.rs +++ b/crates/text/src/thread.rs @@ -34,7 +34,11 @@ pub fn story_paras(frames: &[&TextObject], later_wins: &[bool]) -> Vec