mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 04:25:52 -05:00
New document: a replayed rows count over 1000 is kept to 1000
A file.new step replayed from a journal or the Actions panel rounded artboardLayout.rows and then refused a result over 1000, so a step with rows 1000.5 or 5000 stopped the playback. The rows count now follows the columns rule: it is rounded, must be 1 or more, and is kept to at most 1000. Recent stores the kept count. docs/mcp.md says the same.
This commit is contained in:
1 parent
44b238b814
commit
b51d13d2a4
4 files changed
+10
-5
No files matched your search
@@ -395,7 +395,7 @@ impl DocSettings {
|
||||
}
|
||||
"rows" => {
|
||||
self.rows = if replaying {
|
||||
v.as_f64().map(f64::round).filter(|n| (1.0..=f64::from(MAX_ARTBOARDS)).contains(n)).map(|n| n as u32)
|
||||
v.as_f64().map(f64::round).filter(|n| *n >= 1.0).map(|n| n.min(f64::from(MAX_ARTBOARDS)) as u32)
|
||||
} else {
|
||||
count(v)
|
||||
}
|
||||
|
||||
@@ -219,6 +219,8 @@ fn replayed_counts_keep_their_rounding_and_range_rules() {
|
||||
("rows", 2.4, 2),
|
||||
("rows", 0.6, 1),
|
||||
("rows", 1000.4, 1000),
|
||||
("rows", 1000.6, 1000),
|
||||
("rows", 5000.0, 1000),
|
||||
] {
|
||||
let mut p = json!({"width": 10, "height": 10, "artboards": 4,
|
||||
"artboardLayout": {"layout": "gridByColumn", "spacing": 0}});
|
||||
@@ -236,8 +238,11 @@ fn replayed_counts_keep_their_rounding_and_range_rules() {
|
||||
p["artboardLayout"][key] = json!(expected);
|
||||
}
|
||||
assert_eq!(boards(&s), boards(&new_doc(p)));
|
||||
if key == "rows" {
|
||||
assert_eq!(presets(&mut s, "Recent")[0]["artboardLayout"]["rows"], json!(expected), "{value}");
|
||||
}
|
||||
}
|
||||
for layout in [json!({"columns": 0.6}), json!({"rows": 0.4}), json!({"rows": 1000.6})] {
|
||||
for layout in [json!({"columns": 0.6}), json!({"rows": 0.4})] {
|
||||
let mut p = json!({"artboardLayout": layout});
|
||||
p["artboardLayout"]["layout"] = json!("gridByColumn");
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -1306,10 +1306,10 @@ fn file_new_takes_the_rows_of_a_grid_by_column() {
|
||||
|
||||
#[test]
|
||||
fn file_new_replays_legacy_fractional_and_large_rows() {
|
||||
for (rows, rounded) in [(3.6, 4), (1000.4, 1000)] {
|
||||
for (rows, rounded) in [(3.6, 4), (1000.4, 1000), (1000.5, 1000), (5000.0, 1000)] {
|
||||
let params = json!({"width": 100, "height": 100, "artboards": 5, "artboardLayout": {"layout": "gridByColumn", "rows": rows}});
|
||||
let mut s = Session::new();
|
||||
// A direct call refuses a fraction; a replay rounds it to a count from 1 to 1000.
|
||||
// A direct call refuses a fraction or a count over 1000; a replay rounds it and keeps it to at most 1000.
|
||||
let direct = Session::new().execute("file.new", ¶ms);
|
||||
assert!(direct.is_err(), "{rows}: {direct:?}");
|
||||
s.replay("file.new", ¶ms).unwrap();
|
||||
|
||||
+1
-1
@@ -636,7 +636,7 @@ left out or null; `appearance.setActiveItem` reads a null `index` as clearing th
|
||||
whole number from 1 to 1000, such as `2.4`, `0` or `1001`, and opens no document. A null `artboards` keeps the
|
||||
default or the preset's count; a null `columns` or `rows` is an error. A `file.new` step replayed from a journal or
|
||||
played from the Actions panel keeps the earlier rules: `artboards` is rounded and kept within 1 to 1000, a `columns` of
|
||||
1 or more is rounded and kept to at most 1000, and a `rows` is rounded and must then be from 1 to 1000.
|
||||
1 or more is rounded and kept to at most 1000, and a `rows` is rounded, must then be 1 or more, and is kept to at most 1000.
|
||||
A command that leaves out an object selected inside a
|
||||
selected group also leaves it out when `ids` list it together with a group that holds it. Every command that takes
|
||||
`ids` (or `slices`, for the slice commands) refuses a list with an entry that is not a non-negative integer, or a value
|
||||
|
||||
Reference in new issue
Block a user