Review: Layer Options reuses the translated id messages; ROADMAP (#1077)

The new id errors reuse messages the catalogs already translate
(`ids` must be an array of object ids, object ids are non-negative
integers, no such layer or object), so complete_languages_translate_every_message
keeps passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-11 07:43:13 +07:00
co-authored by Claude Opus 5.5
parent d47857a20f
commit a031ff6c7b
2 changed files with 17 additions and 22 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+16 -21
View File
@@ -54,21 +54,20 @@ fn fields_of(n: &Node) -> serde_json::Map<String, Value> {
/// the current layer), filled in from the first.
pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
let st = app.session.active().ok_or("no document open")?;
let parse_id = |value: &Value| -> Result<NodeId, String> {
let id = NodeId(value.as_u64().ok_or_else(|| format!("invalid layer or object id: {value}"))?);
st.doc.node(id).ok_or_else(|| format!("no such layer or object id: {}", id.0))?;
Ok(id)
// Rows given are used as given: a malformed or unknown id fails rather than being skipped or
// the dialog opening on the highlighted rows instead.
let row = |v: &Value| -> Result<NodeId, String> {
let id = NodeId(v.as_u64().ok_or_else(|| format!("object ids are non-negative integers, not {v}"))?);
st.doc.node(id).map(|_| id).ok_or_else(|| "no such layer or object".to_string())
};
let ids: Vec<NodeId> = match p.get("ids") {
Some(Value::Array(values)) => values.iter().map(parse_id).collect::<Result<_, _>>()?,
Some(_) => return Err("`ids` must be an array of layer or object ids".into()),
None => match p.get("id") {
Some(value) => vec![parse_id(value)?],
None => {
let rows = st.highlighted_rows();
if rows.is_empty() { st.current_layer().into_iter().collect() } else { rows }
}
},
let ids: Vec<NodeId> = match (p.get("ids"), p.get("id")) {
(Some(Value::Array(a)), _) => a.iter().map(row).collect::<Result<_, _>>()?,
(Some(v), _) => return Err(format!("`ids` must be an array of object ids, not {v}")),
(None, Some(v)) => vec![row(v)?],
(None, None) => {
let rows = st.highlighted_rows();
if rows.is_empty() { st.current_layer().into_iter().collect() } else { rows }
}
};
let first = ids.first().and_then(|id| st.doc.node(*id)).ok_or("no such layer or object")?;
let mut f = fields_of(first);
@@ -265,13 +264,9 @@ mod tests {
fn invalid_layer_options_targets_do_not_open_a_partial_dialog() {
let mut app = app();
let id = app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap();
for params in [
json!({"ids": [id, "invalid"]}),
json!({"ids": [id, 999999]}),
json!({"ids": "invalid"}),
json!({"id": "invalid"}),
json!({"id": null}),
] {
for params in
[json!({"ids": [id, "invalid"]}), json!({"ids": [id, 999999]}), json!({"ids": "invalid"}), json!({"id": "invalid"}), json!({"id": null})]
{
assert!(app.run("ui.layerOptions", params.clone()).is_err(), "accepted {params}");
assert!(app.ui.dialog.is_none(), "opened partial options for {params}");
}