mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 09:54:09 +01:00
Symbols: symbol.spray refuses a style that is not a name
A style parameter that is not a string was read as no style, and the default style applied. It is now an error.
This commit is contained in:
1 parent
86694a1b30
commit
a8abd874f2
2 files changed
+5
No files matched your search
@@ -941,6 +941,9 @@ pub(super) fn symbol_spray(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(c) => crate::cmd::paint::new_color(s, p, c),
|
||||
None => s.paint.fill.color().unwrap_or(Color::BLACK),
|
||||
};
|
||||
if let Some(v) = p.get("style").filter(|v| !v.is_string()) {
|
||||
return Err(bad(C, format!("`style` must be a graphic style's name, not {v}")));
|
||||
}
|
||||
let style = style_paint(&st.doc, p);
|
||||
// Style: User Defined uses the style `style` names, so one the document does not have is an error.
|
||||
if let Some(n) = str_param(p, "style").filter(|_| !modes.style && style.is_none()) {
|
||||
|
||||
@@ -491,6 +491,8 @@ fn bad_sprayer_attributes_are_refused() {
|
||||
// Style: User Defined with a style the document does not have; Average does not use it.
|
||||
let user = json!({"name": "Dot", "points": [[200, 150]], "attributes": {"style": "userDefined"}, "style": "Nope"});
|
||||
refused(&mut s, "symbol.spray", user, "unknown graphic style `Nope`");
|
||||
let number = json!({"name": "Dot", "points": [[200, 150]], "attributes": {"style": "userDefined"}, "style": 3});
|
||||
refused(&mut s, "symbol.spray", number, "`style` must be a graphic style's name, not 3");
|
||||
let average = json!({"name": "Dot", "points": [[200, 150]], "style": "Nope"});
|
||||
assert_eq!(s.execute("symbol.spray", &average).unwrap()["count"], 1);
|
||||
let all = json!({"scrunch": "average", "size": "userDefined", "spin": null, "screen": "average", "stain": "average", "style": "average"});
|
||||
|
||||
Reference in new issue
Block a user