diff --git a/crates/engine-core/src/cmd/type_anti_alias_history_tests.rs b/crates/engine-core/src/cmd/type_anti_alias_history_tests.rs new file mode 100644 index 00000000000..6355bf4765b --- /dev/null +++ b/crates/engine-core/src/cmd/type_anti_alias_history_tests.rs @@ -0,0 +1,33 @@ +//! #17959: each Type › Anti-Alias method adds one History state named after the method, as the +//! reference application names it ("Anti Alias Crisp"), instead of one shared name for all seven. + +use serde_json::json; + +use crate::Session; + +/// A document with one type layer, and that layer's id. +fn session() -> (Session, u64) { + let mut s = crate::session(); + s.execute("file.new", json!({"width": 300, "height": 200})).unwrap(); + let layer = s.execute("type.create", json!({"text": "Ab", "x": 40, "y": 120})).unwrap()["layer"].as_u64().unwrap(); + (s, layer) +} + +#[test] +fn each_method_names_its_own_history_state() { + let (mut s, layer) = session(); + // New text is Smooth, so every command here changes the method. + for (cmd, name) in [ + ("type.antiAlias.none", "Anti Alias None"), + ("type.antiAlias.sharp", "Anti Alias Sharp"), + ("type.antiAlias.crisp", "Anti Alias Crisp"), + ("type.antiAlias.strong", "Anti Alias Strong"), + ("type.antiAlias.smooth", "Anti Alias Smooth"), + ("type.antiAlias.windowsLcd", "Anti Alias Windows LCD"), + ("type.antiAlias.windows", "Anti Alias Windows"), + ] { + let before = s.active().unwrap().history.entries().len(); + s.execute(cmd, json!({"layer": layer})).unwrap(); + assert_eq!(s.active().unwrap().history.entries()[before..], [name], "{cmd}"); + } +} diff --git a/crates/engine-core/src/cmd/type_extra_cmds.rs b/crates/engine-core/src/cmd/type_extra_cmds.rs index 051667b3587..c3ce98effe2 100644 --- a/crates/engine-core/src/cmd/type_extra_cmds.rs +++ b/crates/engine-core/src/cmd/type_extra_cmds.rs @@ -137,7 +137,17 @@ pub fn aa_name(a: AntiAlias) -> &'static str { } fn set_aa(s: &mut Session, p: &Value, aa: AntiAlias) -> Result { - with_text_targets(s, p, "Anti-Alias", |t, _| { + // The History state is named after the method, as in the reference application (#17959). + let label = match aa { + AntiAlias::None => "Anti Alias None", + AntiAlias::Sharp => "Anti Alias Sharp", + AntiAlias::Crisp => "Anti Alias Crisp", + AntiAlias::Strong => "Anti Alias Strong", + AntiAlias::Smooth => "Anti Alias Smooth", + AntiAlias::WindowsLcd => "Anti Alias Windows LCD", + AntiAlias::Windows => "Anti Alias Windows", + }; + with_text_targets(s, p, label, |t, _| { t.antialias = aa; Ok(()) })?; @@ -1127,3 +1137,7 @@ pub fn specs() -> Vec { #[cfg(test)] #[path = "type_extra_cmds/tests.rs"] mod tests; + +#[cfg(test)] +#[path = "type_anti_alias_history_tests.rs"] +mod anti_alias_history_tests;