Compare commits

...
Author SHA1 Message Date
autocraft-bot[bot] 3f67bded2c Merge main (8413f81a) into the pull request
I resolved the one conflict in crates/engine/src/cmd/slide.rs, in the te

I resolved the one conflict in crates/engine/src/cmd/slide.rs, in the tests module. The pull request's `delete_reports_only_slides_it_deleted` test and the default branch's `removing_a_section_with_its_slides_prunes_them_from_custom_shows` test both stay, as two separate tests. The pull request's change to `delete` itself merged cleanly, and it sits alongside the default branch's pruning of custom shows. No conflict markers are left. `cargo fmt --check` is clean and `cargo clippy --all-targets` for the engine crate shows no new warnings. The 92 engine tests matching `slide` pass.
2026-12-02 18:25:49 +00:00
Simon Koch-Sultan 39fd7ed90f engine: slide.delete reports only the slides it deleted 2026-11-28 08:40:13 +00:00
+18
View File
@@ -262,6 +262,13 @@ fn delete(s: &mut Session, p: &Value) -> Result<Value> {
return Err(bad("slide.delete", "no such slide"));
}
s.edit(|doc, sel| {
// Count only slides that are in the deck, each once: an id that names no slide, or a
// repeat, deletes nothing and must not be reported as deleted.
let mut seen = HashSet::new();
let ids: Vec<SlideId> = ids.iter().copied().filter(|id| doc.slide_index(*id).is_some() && seen.insert(*id)).collect();
if ids.is_empty() {
return Err(bad("slide.delete", "no such slide"));
}
let first = ids.iter().filter_map(|id| doc.slide_index(*id)).min().unwrap_or(0);
doc.slides.retain(|x| !ids.contains(&x.id));
for sec in &mut doc.sections {
@@ -987,6 +994,17 @@ mod tests {
assert_eq!(selected(&s), (0, vec![ids[2]]));
}
#[test]
fn delete_reports_only_slides_it_deleted() {
let (mut s, ids) = deck(3);
assert!(s.execute("slide.delete", &json!({"ids": [999_999]})).is_err(), "an id that names no slide deletes nothing");
assert_eq!(order(&s), ids);
let r = s.execute("slide.delete", &json!({"ids": [ids[1], ids[1], 999_999]})).expect("delete");
assert_eq!(order(&s), [ids[0], ids[2]]);
assert_eq!(r["deleted"], 1, "{r}");
assert_eq!(r["remaining"], 2, "{r}");
}
#[test]
fn removing_a_section_with_its_slides_prunes_them_from_custom_shows() {
let (mut s, ids) = deck(4);