diff --git a/crates/engine/src/cmd/views.rs b/crates/engine/src/cmd/views.rs index 90f2656d7..f4db493d6 100644 --- a/crates/engine/src/cmd/views.rs +++ b/crates/engine/src/cmd/views.rs @@ -52,7 +52,8 @@ static TRANSPARENCY_GRID: ParamSchema = ParamSchema::new( &[Param::new("on", Type::Boolean).default_note("toggle").null_omitted()], "show the transparency grid behind the active document's artboards (each document has its own setting)", ) -.returns("{on}"); +.returns("{on}") +.writes(Writes::Session); static GLYPH_SNAP: ParamSchema = ParamSchema::new( &[ diff --git a/crates/engine/src/schemas.rs b/crates/engine/src/schemas.rs index d2cca1e19..8a203530a 100644 --- a/crates/engine/src/schemas.rs +++ b/crates/engine/src/schemas.rs @@ -29,7 +29,7 @@ use crate::{EngineError, Result}; pub const API_VERSION: u32 = 1; /// [`schema_hash`] at each API level, oldest first; the last row is [`API_VERSION`]'s. -pub const SCHEMA_HASHES: &[(u32, u64)] = &[(1, 0x7552_6395_fcbb_1b90)]; +pub const SCHEMA_HASHES: &[(u32, u64)] = &[(1, 0xda5b_4c1e_fe4e_c697)]; /// The hash of every built-in command's schema ([`vectorcraft_apischema::hash`]). pub fn schema_hash() -> u64 { @@ -312,6 +312,25 @@ mod tests { assert!(without.get("schema").is_none()); } + /// The listing says what each View command changes when it runs. Only the commands that make an + /// undo step list `document`. + #[test] + fn each_view_command_lists_what_it_writes() { + let listed: Vec<(&str, Value)> = schemas().into_iter().map(|(id, schema)| (id, schema.to_json()["x-writes"].clone())).collect(); + let expected = [ + ("view.capsLock", "session"), + ("view.saved.new", "document"), + ("view.saved.edit", "document"), + ("view.saved.list", "nothing"), + ("view.transparencyGrid", "session"), + ("view.snapToGlyph.options", "preferences"), + ]; + for (id, writes) in expected { + let got = listed.iter().find(|(c, _)| *c == id).map(|(_, w)| w.clone()); + assert_eq!(got, Some(json!(writes)), "{id}"); + } + } + /// Values of type `ty` that pass it. fn valid(ty: Type) -> BoxedStrategy { fn number(min: Option, max: Option) -> BoxedStrategy {