From c79416be4c5a07dc859eaf3271d9e455fa7430d5 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 14 Oct 2026 16:24:26 -0400 Subject: [PATCH] Fix up merged PRs: no debug_assert in blank_presentation; more exhaustion coverage blank_presentation's debug_assert would panic in debug builds (never-crash rule): a fresh deck that cannot fit its title slide now simply arrives without it. The exhaustion test also covers insert.smartArt and insert.textBox. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests.rs | 2 ++ crates/model/src/defaults.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 1a6238ee..08028f84 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3469,6 +3469,8 @@ fn an_exhausted_id_space_refuses_growth() { assert!(s.execute("shape.insert", &json!({"preset": "rect", "rect": [10, 10, 100, 50]})).is_err()); assert!(s.execute("slide.duplicate", &json!({})).is_err()); assert!(s.execute("edit.duplicate", &json!({})).is_err()); + assert!(s.execute("insert.smartArt", &json!({"kind": "blockList", "items": ["Plan", "Build"]})).is_err()); + assert!(s.execute("insert.textBox", &json!({"text": "Hi"})).is_err()); // What the deck holds is untouched: same slides, same ids, no duplicates. let after = s.doc().unwrap().doc.clone(); assert_eq!(after.slides.len(), before.slides.len()); diff --git a/crates/model/src/defaults.rs b/crates/model/src/defaults.rs index 3645f332..19adc7bb 100644 --- a/crates/model/src/defaults.rs +++ b/crates/model/src/defaults.rs @@ -522,9 +522,9 @@ pub fn blank_presentation(size: Size, theme: Theme, title_slide: bool) -> Presen // A fresh deck starts at id 256 and this builds a handful of ids, so the slide always // fits; should that ever stop holding, the deck arrives without its title slide rather // than with a duplicated id. - let s = new_slide(&mut p, first_layout); - debug_assert!(s.is_some(), "a fresh deck cannot run out of ids"); - p.slides.extend(s.map(|s| vec![Arc::new(s)]).unwrap_or_default()); + if let Some(s) = new_slide(&mut p, first_layout) { + p.slides.push(Arc::new(s)); + } } p }