From c0b505b41d635b4376b5d97325a5357f54ffe717 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 16 Oct 2026 18:40:14 +0700 Subject: [PATCH] Masks: deleting vertices fills in missing tangents first, like add and set (#1250) Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/commands/mask.rs | 1 + crates/engine/src/tests_timeline.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/crates/engine/src/commands/mask.rs b/crates/engine/src/commands/mask.rs index 8da0330a7..778dfb54c 100644 --- a/crates/engine/src/commands/mask.rs +++ b/crates/engine/src/commands/mask.rs @@ -290,6 +290,7 @@ fn edit_vertices_counted(s: &mut Session, p: &Value, label: &str, removes: bool, let roto = super::paths::is_roto(g); let Some(pr) = g.get_mut("path") else { continue }; let KV::Path(mut sp) = pr.value_at(lt) else { continue }; + sp.fit_tangents(); f(&mut sp, idx); if roto { super::paths::roto_smooth(&mut sp); diff --git a/crates/engine/src/tests_timeline.rs b/crates/engine/src/tests_timeline.rs index 50f60014c..72b359641 100644 --- a/crates/engine/src/tests_timeline.rs +++ b/crates/engine/src/tests_timeline.rs @@ -373,6 +373,17 @@ fn vertex_commands_fill_in_missing_tangents_of_a_loaded_path() { assert_eq!(p.in_tangents[1], [0.0, 0.0], "a missing tangent is a corner"); } +#[test] +fn deleting_vertices_of_a_loaded_path_with_short_tangents_does_not_panic() { + let (mut s, l) = setup(); + let m = s.execute("mask.new", json!({"layer": l, "vertices": [[10, 10], [90, 10], [90, 90]]})).unwrap()["mask"].as_u64().unwrap(); + reopen_with_short_tangents(&mut s); + s.execute("mask.selectVertices", json!({"vertices": [{"layer": l, "mask": m, "index": 2}]})).unwrap(); + s.execute("mask.deleteVertices", json!({})).unwrap(); + let p = prop(&s, l, "masks/#1/path").value.as_path().unwrap().clone(); + assert_eq!((p.vertices.len(), p.in_tangents.len(), p.out_tangents.len()), (2, 2, 2)); +} + #[test] fn vertex_commands_fill_in_missing_tangents_of_a_loaded_animated_path() { let (mut s, l) = setup();