Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

M3.8: register the split paint modules next to paint so the command palette keeps listing them (Stroke Options for "stroke")

bflatastic9cabeea68bfe
diff --git a/crates/engine/src/cmd/mod.rs b/crates/engine/src/cmd/mod.rs
index 26dd788f2..1df0c1bcc 100644
--- a/crates/engine/src/cmd/mod.rs
+++ b/crates/engine/src/cmd/mod.rs
@@ -153,6 +153,13 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(select::specs());
v.extend(wand::specs());
v.extend(paint::specs());
+ // Split out of `paint` (M3.8); kept next to it so lists in registry order (the command
+ // palette, `engine.commands`) show them where they always were.
+ v.extend(stroke::specs());
+ v.extend(appearance::specs());
+ v.extend(style::specs());
+ v.extend(swatch::specs());
+ v.extend(gradient::specs());
v.extend(opacitymask::specs());
v.extend(layer::specs());
v.extend(draw2::specs());
@@ -184,11 +191,6 @@ pub fn command_specs() -> &'static [CommandSpec] {
v.extend(patterncmds::specs());
v.extend(prefscmds::specs());
v.extend(distortcmds::specs());
- v.extend(appearance::specs());
- v.extend(gradient::specs());
- v.extend(stroke::specs());
- v.extend(style::specs());
- v.extend(swatch::specs());
v
})
}
diff --git a/crates/engine/src/tests_cmdsplit.rs b/crates/engine/src/tests_cmdsplit.rs
index a14eab535..12e7f56d6 100644
--- a/crates/engine/src/tests_cmdsplit.rs
+++ b/crates/engine/src/tests_cmdsplit.rs
@@ -48,8 +48,13 @@ fn moved_commands_keep_their_ids() {
"swatch.duplicate",
"swatch.sortByName",
];
+ let pos = |id: &str| command_specs().iter().position(|c| c.id == id).unwrap_or_else(|| panic!("{id}"));
+ let (paint_end, after_paint) = (pos("transparency.set"), pos("transparency.makeOpacityMask"));
for id in ids {
assert_eq!(command_specs().iter().filter(|c| c.id == id).count(), 1, "{id}");
+ // Registered right after `paint` (where they lived), so the command palette, which lists
+ // the first matches in registry order, still shows them (e.g. Stroke Options for "stroke").
+ assert!((paint_end..after_paint).contains(&pos(id)), "{id}");
}
}