From 90e44a619f693df4cd0f99ca717359408223bf37 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Fri, 27 Nov 2026 12:46:37 +0000 Subject: [PATCH] Apply review fixes - crates/engine/src/cmd/format/paragraph.rs --- crates/engine/src/cmd/format/paragraph.rs | 40 ++++++++++------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/crates/engine/src/cmd/format/paragraph.rs b/crates/engine/src/cmd/format/paragraph.rs index 5394c5754..6142055c3 100644 --- a/crates/engine/src/cmd/format/paragraph.rs +++ b/crates/engine/src/cmd/format/paragraph.rs @@ -120,30 +120,26 @@ pub(super) fn line_spacing(s: &mut Session, p: &Value) -> Result { } pub(super) fn paragraph(s: &mut Session, p: &Value) -> Result { - if let Err(e) = - require_any(p, "format.paragraph", &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"]) + // The Paragraph dialog's other fields are format.paragraphDialog's; say so instead of + // calling the call empty. + if let Some(k) = + ["special", "specialBy", "indentRight", "spaceBeforeKind", "spaceAfterKind"].into_iter().find(|k| p.get(*k).is_some_and(|v| !v.is_null())) { - // The Paragraph dialog's other fields are format.paragraphDialog's; say so instead of - // calling the call empty. - if let Some(k) = - ["special", "specialBy", "indentRight", "spaceBeforeKind", "spaceAfterKind"].into_iter().find(|k| p.get(*k).is_some_and(|v| !v.is_null())) - { - // The dialog applies a kind or `specialBy` only with the value it qualifies. - let with = match k { - "spaceBeforeKind" => " together with `spaceBefore`", - "spaceAfterKind" => " together with `spaceAfter`", - "specialBy" => " together with `special`", - _ => "", - }; - return Err(bad( - "format.paragraph", - format!( - "`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog); pass it there{with}. format.paragraph does not read it" - ), - )); - } - return Err(e); + // The dialog applies a kind or `specialBy` only with the value it qualifies. + let with = match k { + "spaceBeforeKind" => " together with `spaceBefore`", + "spaceAfterKind" => " together with `spaceAfter`", + "specialBy" => " together with `special`", + _ => "", + }; + return Err(bad( + "format.paragraph", + format!( + "`{k}` is a field of format.paragraphDialog (the whole Paragraph dialog); pass it there{with}. format.paragraph does not read it" + ), + )); } + require_any(p, "format.paragraph", &["align", "indentLeft", "indentFirst", "spaceBefore", "spaceAfter", "lineSpacing", "lineSpacingPt"])?; let a = str_param(p, "align").map(|a| parse_align("format.paragraph", a)).transpose()?; let ml = f64_param(p, "indentLeft"); let ind = f64_param(p, "indentFirst");