#2817: read the selection in place and name the Closed tests for what they prove

This commit is contained in:
arnav-hiwarkar committed 2026-11-12 18:36:20 +05:30
1 parent 0ccfd669fb
commit 5b3a469181
2 files changed
+9 -13

No files matched your search

+7 -11
View File
@@ -17,9 +17,9 @@ struct Target {
editable: bool,
}
struct Selection {
vertices: Vec<VertexRef>,
props: Vec<(LayerId, Uid)>,
struct Selection<'a> {
vertices: &'a [VertexRef],
props: &'a [(LayerId, Uid)],
time: Tick,
}
@@ -36,16 +36,12 @@ fn group_at_mut<'a>(mut group: &'a mut PropGroup, route: &[usize]) -> Option<&'a
/// never falls back to its siblings, and are then left out.
fn targets(s: &Session) -> Result<Vec<Target>> {
let comp = s.active_comp().ok_or(EngineError::NoComp)?;
let on_selected = |lid: &LayerId| s.state.selected_layers.contains(lid);
// Layer navigation and insertion can retain point/property selections on other layers.
let selection = Selection {
vertices: s.state.selected_vertices.iter().filter(|v| on_selected(&v.layer)).copied().collect(),
props: s.state.selected_props.iter().filter(|(lid, _)| on_selected(lid)).copied().collect(),
time: s.time(),
};
let selection = Selection { vertices: &s.state.selected_vertices, props: &s.state.selected_props, time: s.time() };
let mut targets = Vec::new();
for whole_layers in [false, true] {
for layer in comp.layers.iter().filter(|l| on_selected(&l.id)) {
// Only selected layers: navigation and insertion can retain point/property selections
// on other layers, and every match below is per layer.
for layer in comp.layers.iter().filter(|l| s.state.selected_layers.contains(&l.id)) {
collect(&selection, layer, &layer.props, &mut Vec::new(), whole_layers, layer.switches.locked, &mut targets)?;
}
if !targets.is_empty() {
+2 -2
View File
@@ -395,7 +395,7 @@ fn toggle_closed_combines_property_and_shape_group_selections() {
s.execute("shape.newPath", json!({"layer": lid, "vertices": [[20, 20], [80, 20], [80, 80]], "closed": true})).unwrap()["path"].as_u64().unwrap();
s.execute("prop.select", json!({"layer": lid, "prop": a_path})).unwrap();
s.execute("prop.select", json!({"layer": lid, "prop": b_group, "add": true})).unwrap();
assert!(s.state.selected_vertices.iter().all(|v| v.mask == a_path), "only the path property implies selected vertices");
assert!(s.state.selected_vertices.iter().all(|v| v.mask == a_path), "only the selected path group implies selected vertices");
assert!(!s.state.selected_vertices.is_empty());
assert!(s.state.selected_props.contains(&(LayerId(lid), b_group)));
let result = s.execute("path.toggleClosed", json!({})).unwrap();
@@ -528,7 +528,7 @@ fn toggle_closed_recomputes_roto_bezier_tangents() {
}
#[test]
fn toggle_closed_fits_short_tangent_lists_like_set_closed() {
fn toggle_closed_fits_short_tangent_lists() {
let mut s = comp();
let lid = s.execute("layer.newSolid", json!({})).unwrap()["layer"].as_u64().unwrap();
let uid = s.execute("mask.new", json!({"layer": lid, "vertices": [[0, 0], [100, 0], [100, 100]], "closed": true})).unwrap()["mask"].as_u64().unwrap();