mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-16 23:24:42 +00:00
* engine: arrange.align and arrange.distribute refuse values they do not name
arrange.align took an `edge` it did not know as a no-op that still
reported its shapes as edited, aligned left when `edge` was left out
(the spec does not mark it optional), and read any `to` other than
exactly "slide" as the selection. arrange.distribute distributed
vertically for any `dir` starting with "v" and horizontally for any
other, and also read any `to` other than "slide" as the selection.
`edge` must now be left, center, right, top, middle or bottom, `to`
slide or selection, and `dir` horizontal or vertical. Anything else, or
a missing `edge`, is refused with the accepted values and nothing moves.
A missing `to` or `dir` keeps its default.
Test: align_and_distribute_refuse_values_they_do_not_name.
* engine: arrange.align and arrange.distribute refuse a dir or to that is not a string
`align_to` and `distribute` read `to` and `dir` through `str_param`, which
returns None for a value that is present but not a string, the same as for a
missing one. So `{"dir": 123}` distributed horizontally, and
`{"edge": "left", "to": false}` aligned to each command's default reference,
moving the selected shapes instead of failing.
Both now match on `p.get(..).map(Value::as_str)`: a missing field keeps its
default (horizontal for `dir`, each command's own rule for `to`), the named
strings work as before, and anything else, null included, is refused with the
accepted values.
The new test `align_and_distribute_refuse_dir_and_to_that_are_not_strings`
sends null, 123, false, {} and [] as `dir` to arrange.distribute and as `to`
to both commands, in a fresh three-shape session each time, and checks the
error, the revision and every shape's box.