fix: Step and Repeat fill picks the artboard from the whole selection; rustfmt

This commit is contained in:
NetterSilver committed 2026-11-30 08:42:16 +00:00
1 parent da851068bf
commit 07b4332dfc
3 files changed
+24 -3

No files matched your search

+1 -1
View File
@@ -150,7 +150,7 @@ fn step_and_repeat(s: &mut Session, p: &Value) -> Result<Value> {
}
let anchor = if fill {
let sheet = sheet.or_else(|| {
let c = b.center();
let c = d.bounds_of(&roots, false).unwrap_or(b).center();
d.artboards.iter().find(|a| a.rect.contains(c)).or_else(|| d.artboards.first()).map(|a| a.rect)
});
let sheet = sheet.ok_or_else(|| EngineError::Other("no sheet to fill".into()))?;
@@ -155,3 +155,24 @@ fn fractional_gaps_are_exact_except_for_pixel_aligned_objects_which_stay_on_the_
let pitch = gap(true).1;
assert!((pitch - pitch.round()).abs() < 1e-9);
}
#[test]
fn fill_picks_the_artboard_of_the_selection_not_of_the_cut_contour() {
let first_x = |sheet: Option<Value>| {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
s.execute("artboard.new", &json!({"x": 100, "y": 0, "width": 100, "height": 100})).unwrap();
let art = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 60, "height": 20})).unwrap()["id"].as_u64().unwrap();
let cut = s.execute("shape.rectangle", &json!({"x": 105, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap();
s.execute("select.set", &json!({"ids": [art, cut]})).unwrap();
let mut p = json!({"fill": true, "cutId": cut});
if let Some(sh) = sheet {
p["sheet"] = sh;
}
let r = s.execute(CMD, &p).unwrap();
bounds(&s, r["ids"][0].as_u64().unwrap()).0
};
let default = first_x(None);
let explicit = first_x(Some(json!({"x": 100, "y": 0, "width": 100, "height": 100})));
assert!((explicit - default - 100.0).abs() < 1e-9);
}
+2 -2
View File
@@ -4,8 +4,8 @@ use super::path_ops::PathOp;
use super::simplify_slider::StripKind;
use super::{
blend_options, dimension, flare_options, graph_data, graph_design, graph_type, indexed_color, live_paint_gaps, object_mosaic, option_form,
path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, step_repeat, transform,
transform_each, width_point,
path_ops, perspective_grid, perspective_presets, saved_names, shapes, simplify_slider, smooth_slider, step_repeat, transform, transform_each,
width_point,
};
use crate::VectorcraftApp;