DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Autoflow: a frame a Start Paragraph option ends early sets no fill rate (fixes #1209)
VoiceLessQe248b631659c
diff --git a/ROADMAP.md b/ROADMAP.mdindex c02176bab..20525e4a6 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -380,6 +380,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.+- **2026-10-28** · Autoflow no longer sizes the rest of a story by a frame that a Start Paragraph option (next column, frame, page, or odd or even page) ends early (#1209). With a title before a chapter that starts on the next odd page, it estimated a page per few characters, added up to 2000 pages (the autoflow limit) and removed them again: placing 2000 words took 36 s in the app, now 0.4 s, with the same pages. No readiness percentage change.- **2026-10-27** · An iconic panel's flyout stays open while you work in the canvas or a text field: Auto-Collapse Iconic Panels is off by default, and preferences saved with it on start with it off. Preferences › Interface › Panels holds the setting next to the column bar's menu item. No readiness percentage change.- **2026-10-24** · Column rules run from the top line's ascent to the bottom line's descent, as InDesign draws them, instead of from the top to the bottom of the columns, on screen, in PDF and in PowerPoint export. The top and bottom insets shorten the rule from those lines. Existing documents draw their column rules at the new length. No readiness percentage change.- **2026-10-20** · Edit › Keyboard Shortcuts is craft-keymap's shared dialog: commands grouped by menu with Show and Filter, recording that asks before taking a key from another command, undo and redo, named shortcut sets (edits of Default become Custom; an imported set becomes a set of its own), an on-screen US keyboard, InDesign Show Set files reviewed before they apply, JSON export and an HTML summary. ui.json keeps the `shortcuts` map earlier versions read, for the active set. No readiness percentage change.diff --git a/crates/engine/src/cmd/place_text.rs b/crates/engine/src/cmd/place_text.rsindex 4f9aaf1aa..7932a185c 100644--- a/crates/engine/src/cmd/place_text.rs+++ b/crates/engine/src/cmd/place_text.rs@@ -3,7 +3,7 @@//! until the whole story fits (InDesign's Shift-click with a loaded text cursor).use designcraft_doc::{- CharacterStyle, Content, Document, ParaFormat, ParagraphStyle, SpreadRef, Story, StoryId, TextDirection, TextFileLink, TextSel,+ CharacterStyle, Content, Document, ParaFormat, ParagraphStyle, SpreadRef, StartParagraph, Story, StoryId, TextDirection, TextFileLink, TextSel,};use designcraft_geom::Rect;use serde_json::{Value, json};@@ -199,14 +199,21 @@ pub(crate) fn reimport(/// Is the story overset in its frames, and how much text do its full frames hold (bytes, frames)?/// A frame a column, frame or page break ends early is left out: it says nothing about how much-/// a frame holds.+/// a frame holds. So is one a Start Paragraph option ends early (#1209).fn fit(d: &Document, sid: StoryId) -> (Option<usize>, usize, usize) {let cs = designcraft_compose::compose_story(d, sid, &Default::default());- let text = d.story(sid).map_or("", |s| s.text.as_str());+ let Some(story) = d.story(sid) else { return (cs.overset_at, 0, 0) };+ let text = story.text.as_str();+ // A frame's range stops before the paragraph's return.+ let moved_on = |end: usize| {+ let next = if text.as_bytes().get(end) == Some(&b'\n') { end.saturating_add(1) } else { end };+ next.checked_sub(1).is_some_and(|i| text.as_bytes().get(i) == Some(&b'\n'))+ && story.paras.get(story.para_at(next)).is_some_and(|p| d.styles.resolve_para(p).0.start_paragraph != StartParagraph::Anywhere)+ };let (mut held, mut full) = (0, 0);for f in &cs.frames {let Some(shown) = text.get(f.range.clone()) else { continue };- if !shown.is_empty() && !shown.chars().any(designcraft_doc::is_break_char) {+ if !shown.is_empty() && !shown.chars().any(designcraft_doc::is_break_char) && !moved_on(f.range.end) {held += shown.len();full += 1;}diff --git a/crates/engine/src/cmd/place_text/tests.rs b/crates/engine/src/cmd/place_text/tests.rsindex 006762ab2..bdce2a975 100644--- a/crates/engine/src/cmd/place_text/tests.rs+++ b/crates/engine/src/cmd/place_text/tests.rs@@ -307,3 +307,40 @@ fn autoflow_adds_the_pages_odd_and_even_page_breaks_ask_for() {assert_eq!(designcraft_compose::compose_story(&d, sid, &Default::default()).overset_at, None, "{brk:?}");}}++#[test]+fn autoflow_sizes_no_frame_by_one_a_start_option_ends_early() {+ // Regression (#1209): the title frame a start option ends early isn't a frame's worth of text.+ use std::io::Write;+ const W: &str = r#"xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main""#;+ let para = |style: &str, text: &str| format!(r#"<w:p><w:pPr><w:pStyle w:val="{style}"/></w:pPr><w:r><w:t>{text}</w:t></w:r></w:p>"#);+ let body = [para("Title", "Front"), para("Chapter", "Chapter one"), para("Body", "lorem ipsum dolor sit amet ".repeat(60).trim())].concat();+ let styles: String = ["Title", "Chapter", "Body"]+ .iter()+ .map(|s| format!(r#"<w:style w:type="paragraph" w:styleId="{s}"><w:name w:val="{s}"/></w:style>"#))+ .collect();+ let mut w = zip::ZipWriter::new(std::io::Cursor::new(Vec::new()));+ let o = zip::write::SimpleFileOptions::default();+ for (n, c) in [+ ("word/document.xml", format!(r#"<w:document {W}><w:body>{body}</w:body></w:document>"#)),+ ("word/styles.xml", format!(r#"<w:styles {W}>{styles}</w:styles>"#)),+ ] {+ w.start_file(n, o).unwrap();+ w.write_all(c.as_bytes()).unwrap();+ }+ let docx = w.finish().unwrap().into_inner();+ for (start, pages) in [("nextOddPage", 5), ("nextEvenPage", 4)] {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 3, "facingPages": true})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Chapter", "para": {"startParagraph": start}})).unwrap();+ let ids = s.doc().unwrap().doc.next_id;+ let r = s+ .execute("file.place", &json!({"base64": super::super::file::base64_encode(&docx), "name": "front.docx", "page": 3, "autoflow": true}))+ .unwrap();+ assert_eq!(r["overset"], false, "{start}: {r}");+ let d = &s.doc().unwrap().doc;+ assert_eq!(d.page_count(), pages, "{start}: {r}");+ // A few ids per page it keeps, not hundreds for pages it builds and removes.+ assert!(d.next_id - ids < 100, "{start}: {} ids", d.next_id - ids);+ }+}