From 01220df57928a6148d4779eeea9b2fbbdb737c54 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Mon, 2 Nov 2026 04:51:01 -0500 Subject: [PATCH] design.background: check the index before a picture is added to the media Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/design/slide_background.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/design/slide_background.rs b/crates/engine/src/cmd/design/slide_background.rs index 92f3ce77..494b53be 100644 --- a/crates/engine/src/cmd/design/slide_background.rs +++ b/crates/engine/src/cmd/design/slide_background.rs @@ -7,6 +7,8 @@ pub(super) fn background(s: &mut Session, p: &Value) -> Result { if bool_or(p, "copy", false) { return copy_slide_background(s); } + // Check the index before anything is edited: a picture is added to the media first. + let index = opt_usize_param(p, "index", "design.background")?; let props = p.get("pictureProps").filter(|v| v.is_object()).cloned(); let transparency = f64_param(p, "transparency"); let reset = bool_or(p, "reset", false); @@ -62,7 +64,6 @@ pub(super) fn background(s: &mut Session, p: &Value) -> Result { )); }; let all = bool_or(p, "all", false); - let index = opt_usize_param(p, "index", "design.background")?; if matches!(op, BgOp::Adjust) { let next = { let st = s.doc()?;