From 5080a8eced487d7b4e6030c199349bdac516a620 Mon Sep 17 00:00:00 2001 From: HassanKhan Date: Tue, 10 Nov 2026 22:13:23 +0500 Subject: [PATCH] text.spelling.editDictionary: say each list entry must be a single word (part of #4936) --- crates/engine/src/cmd/spelling.rs | 6 +++--- crates/engine/src/tests/spelling.rs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/spelling.rs b/crates/engine/src/cmd/spelling.rs index 641f6a4fe..35d1a1277 100644 --- a/crates/engine/src/cmd/spelling.rs +++ b/crates/engine/src/cmd/spelling.rs @@ -370,9 +370,9 @@ fn word_list(p: &Value, key: &str, command: &str) -> Result> { words .iter() .map(|w| { - w.as_str().and_then(craft_proof::custom_word).ok_or_else(|| { - bad(command, format!("`{key}` must hold words of one word, at most {} characters", craft_proof::MAX_CUSTOM_WORD_CHARS)) - }) + w.as_str() + .and_then(craft_proof::custom_word) + .ok_or_else(|| bad(command, format!("`{key}` must hold single words of at most {} characters", craft_proof::MAX_CUSTOM_WORD_CHARS))) }) .collect() } diff --git a/crates/engine/src/tests/spelling.rs b/crates/engine/src/tests/spelling.rs index 889458ac5..16d7f0199 100644 --- a/crates/engine/src/tests/spelling.rs +++ b/crates/engine/src/tests/spelling.rs @@ -291,6 +291,8 @@ fn a_dictionary_edit_is_saved_whole_or_not_at_all() { assert!(s.execute(EDIT, &p).is_err(), "{EDIT} refuses a bad list"); assert!(in_dictionary(&mut s, "pqzvkb"), "{EDIT} changed nothing"); } + let e = s.execute(EDIT, &json!({"add": ["a b"]})).unwrap_err().to_string(); + assert!(e.contains("must hold single words of at most 64 characters"), "{e}"); run(&mut s, EDIT, json!({"remove": ["pqzvkb", "pqzvkc"]})); assert!(!in_dictionary(&mut s, "pqzvkb") && !in_dictionary(&mut s, "pqzvkc")); }