Merge pull request #4896 from WadahBadawi/fix/pathfinder-crop

fix(pathops): enable object.pathfinder.crop on single selected group
This commit is contained in:
BFlat
2026-10-31 23:52:15 +07:00
committed by GitHub
3 changed files with 22 additions and 3 deletions
+4
View File
@@ -185,3 +185,7 @@ sync_github_name = true
display_name = "Arshiya"
real_name = "Arshiya Rahgozar"
sync_github_name = false
[people.WadahBadawi]
display_name = "Wadah Badawi"
sync_github_name = true
+3 -3
View File
@@ -15,8 +15,8 @@ use vectorcraft_pathops::{BoolOp, PathfinderOp};
use super::edit::selected_roots;
use super::{
CommandSpec, EngineError, Result, Session, always, bad, bool_or, checked_ids_or_selection, cmd, has_doc, has_multi, has_selection, number_or,
str_param, switch_or,
CommandSpec, EngineError, Result, Session, always, bad, bool_or, checked_ids_or_selection, cmd, has_doc, has_selection, number_or, str_param,
switch_or,
};
pub fn specs() -> Vec<CommandSpec> {
@@ -90,7 +90,7 @@ pub fn specs() -> Vec<CommandSpec> {
["Window", "Pathfinder"],
None,
"{ids?: [id…] (selected first; default: the selection), precision?: pt 0.001..10, removeRedundantPoints?: bool, removeUnpainted?: bool (default: the Pathfinder Options, see object.pathfinder.options; the values used join the journal entry)} operate on the selected objects (back → front) → {ids}",
has_multi,
has_selection,
|s, p| run_pf(s, p, PathfinderOp::Crop)
),
cmd!(
+15
View File
@@ -1293,3 +1293,18 @@ fn pathfinder_journal_entries_replay_with_the_options_they_used() {
// Options given as params are checked as object.pathfinder.options checks them.
assert!(s.execute("object.pathfinder.divide", &json!({"precision": 20})).is_err());
}
/// A single group containing multiple overlapping paths is accepted by Crop.
#[test]
fn crop_operates_on_a_single_selected_group_of_paths() {
let mut s = session();
let a = rect(&mut s, 0.0, 0.0, 100.0, 100.0);
let b = rect(&mut s, 50.0, 50.0, 100.0, 100.0);
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
let g = s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap();
s.execute("select.set", &json!({"ids": [g]})).unwrap();
assert_eq!(s.doc().unwrap().selection.len(), 1);
let out = s.execute("object.pathfinder.crop", &json!({})).unwrap();
let cropped_ids = ids(&out);
assert!(!cropped_ids.is_empty());
}