Repository navigation
Artboards: delete several artboards and their guides in one pass - #7296
Conversation
Delete Artboards, Delete Empty Artboards and Cut Artboard removed the chosen artboards one at a time, walking every ruler guide and the layer tree once per artboard. They now share one helper that removes the artboards in one walk and their guides in one more, leaving the same artboards, guides and selected guides as before. Empty Artboards in Artwork Cleanup had its own copy of the one-pass removal. It now calls the same helper, and its test reads that helper's walk counter.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Merged, thanks @dotCooCoo! It passed its CI checks. |
What and why
Delete Artboards, Delete Empty Artboards and Cut Artboard removed their artboards one at a time. For each artboard,
Vec::removeshifted every later artboard, andretain_guides(crates/doc/src/document_guides.rs) collected every ruler guide and walked the layer tree again. Deleting k of n artboards with G guides cost about k × (n + G + the layer tree). The help page describes selecting one or more artboards and deleting them with one command, and Delete Empty Artboards in the Artboards panel menu as removing every empty artboard at once, at Delete artboards.remove_artboards(crates/engine/src/cmd/layer.rs) drops all the chosen artboards in oneVec::retain, retires each removed artboard's id, and callsretain_guidesonce with the set of removed ids. It returns "no such artboard" for an index past the end and "a document needs at least one artboard" when every artboard is chosen, before it changes anything.crates/engine/src/cmd/panelcmds.rs) and Artwork Cleanup's Empty Artboards (crates/engine/src/cmd/addons/cleanup/checks.rs) call the same helper instead of their own copies of the removal.docs/target-app-parity.mdhas one line for it under Delete Empty Artboards.The result does not change: the same artboards, guides, selected guides and key guide are left, each command is still one undo step,
artboard.deleteEmptyreturns the samedeletedindices, Delete Artboard and Cut Artboard still refuse locked artboards, Delete Empty Artboards still leaves them, and a document still keeps at least one artboard.How it was tested
New tests in
crates/engine/src/tests/panelcmds.rs, each failing without the change (with the per-artboard loop they count 42 and 58 walks instead of 2):deleting_many_artboards_walks_the_artboards_and_guides_once: 40 artboards, each with a guide, plus a guide on no artboard, all selected, with the key guide on a deleted artboard. Deleting 21 of them walks the artboards once and the guides once, leaves the same artboards, guides, selected guides and key guide as deleting them one at a time, takes one undo step, and Undo brings back all 40 artboards and 41 guides.delete_empty_and_cut_artboards_walk_the_artboards_and_guides_once: Delete Empty Artboards with 29 of 30 artboards empty, and Cut Artboard of 26 of 30, each with two walks and the same result as deleting one at a time. Cutting all four artboards left is refused and leaves them.The existing test
cmd::addons::cleanup::tests::deleting_many_empty_artboards_walks_the_artboards_and_guides_oncenow reads the shared helper's walk counter.Focused checks on the final tree, on Linux. The branch is one commit on
mainatc9b2119552and merges cleanly with it. It conflicts with open #7229 incrates/engine/src/cmd.rs.cargo fmt --all -- --checkcargo clippy -p vectorcraft-engine --all-targets -- -D warningscargo check --workspace --testscargo test -p vectorcraft-engine --lib artboard: 248 passed, 0 failedcargo test -p vectorcraft-engine --lib cleanup: 35 passed, 0 failedcargo xtask brands,layers(30 crates) andassets(337 files)cargo xtask ciruns in this pull request's CI.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.Summary by CodeRabbit