From 27b2bce604279189b01a93c0bd3907c139a5f1c7 Mon Sep 17 00:00:00 2001 From: Abdo Date: Wed, 6 Dec 2023 03:06:28 +0300 Subject: [PATCH] Do not add a fallback field reference if front side contains conditionals (#2859) * Do not add a fallback field ref if front contains conditionals * Ensure field reference when there are only conditionals --- rslib/src/template.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 5b92f04a6..39a59d9fc 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -741,9 +741,9 @@ impl ParsedTemplate { } pub(crate) fn contains_field_replacement(&self) -> bool { - self.0 - .iter() - .any(|node| matches!(node, ParsedNode::Replacement { key: _, filters: _ })) + let mut set = HashSet::new(); + find_field_references(&self.0, &mut set, false, false); + !set.is_empty() } pub(crate) fn add_missing_field_replacement(&mut self, field_name: &str, is_cloze: bool) {