Keep auto-advance when transition.timing gets an invalid after

Found while testing crates/engine/src/cmd/transition.rs:112-115 (timing)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-10-25 07:02:08 +00:00
co-authored by Claude Haiku 5.5
parent a0eeb341d2
commit 8a730912c2
2 changed files with 19 additions and 1 deletions
+5 -1
View File
@@ -111,7 +111,11 @@ fn timing(s: &mut Session, p: &Value) -> Result<Value> {
}
match p.get("after") {
Some(Value::Null) => t.advance_after_ms = None,
Some(v) => t.advance_after_ms = v.as_u64().map(|x| x.min(86_400_000) as u32),
Some(v) => {
if let Some(x) = v.as_u64() {
t.advance_after_ms = Some(x.min(86_400_000) as u32);
}
}
None => {}
}
}
+14
View File
@@ -5406,3 +5406,17 @@ fn slide_hide_and_layout_reject_invalid_index() {
}
assert!(s.doc().unwrap().doc.slides.iter().all(|x| !x.hidden));
}
#[test]
fn transition_timing_invalid_after_keeps_value() {
let mut s = session();
let after = |s: &Session| s.doc().unwrap().doc.slides[0].transition.as_ref().and_then(|t| t.advance_after_ms);
s.execute("transition.timing", &json!({"after": 5000})).unwrap();
assert_eq!(after(&s), Some(5000));
for bad in [json!(-5), json!(1.5), json!("abc")] {
let _ = s.execute("transition.timing", &json!({"after": bad}));
assert_eq!(after(&s), Some(5000), "after:{bad} must not clear the auto-advance");
}
s.execute("transition.timing", &json!({"after": null})).unwrap();
assert_eq!(after(&s), None);
}