Frame from Layers: a blank name takes "Frame N" too (#17329)

A `name` of "" or spaces passed the guard and reached the grouping, which
reads a blank name as none and named the frame "Group N". Treat a blank
name as absent here as well. A name that is not text is still forwarded,
so the grouping refuses it as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
dholzricandClaude Fable 5.2 committed 2026-11-29 15:22:51 -06:00
1 parent 23d1a505aa
commit 35668afe69
2 files changed
+15 -1

No files matched your search

+2 -1
View File
@@ -162,8 +162,9 @@ fn frame_from_layers(s: &mut Session, p: &Value) -> Result<Value> {
.unwrap_or(st.doc.bounds());
let f = geometry(&json!({"x":bounds.x0,"y":bounds.y0,"width":bounds.width(),"height":bounds.height()}))?;
// The frame is the next "Frame N", as an empty frame is, unless the caller names it (#17329).
// A blank name is no name, as it is to the grouping; one that is not text is left for it to refuse.
let mut grouping = p.clone();
if p.get("name").is_none_or(Value::is_null) {
if p.get("name").is_none_or(|n| n.is_null() || n.as_str().is_some_and(|n| n.trim().is_empty())) {
grouping["name"] = json!(st.doc.next_layer_name("Frame"));
}
let journal = s.journal.len();
@@ -64,6 +64,19 @@ fn convert_to_frame_does_not_take_a_frame_number() {
assert_eq!(frame_from(&mut s, &[red]), named("Frame 1", "Red"));
}
#[test]
fn a_blank_name_takes_the_frame_number_as_no_name_does() {
for blank in [json!(""), json!(" "), Value::Null] {
let (mut s, red, _) = session();
let r = s.execute("layer.new.frameFromLayers", json!({"layer": red.0, "name": blank})).unwrap();
let g = s.active().unwrap().doc.layer(LayerId(r["layer"].as_u64().unwrap())).unwrap();
assert_eq!(g.name, "Frame 1", "name {blank:?}");
}
// A name that is not text is still refused, not replaced.
let (mut s, red, _) = session();
assert!(s.execute("layer.new.frameFromLayers", json!({"layer": red.0, "name": 7})).is_err());
}
#[test]
fn the_step_is_add_frame_to_layers_and_a_given_name_wins() {
let (mut s, red, _) = session();