From 4e33775ed4346ef136ece6ef5efec5ba46057c6b Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 29 Apr 2020 21:29:16 +1000 Subject: [PATCH] drop type answer requirement special case While it makes no sense to have the typing box on the front without another non-empty field, "the front of this card is empty" when a typing box is on the template seems to be confusing some users, so it is clearer to show them the box. --- pylib/tests/test_models.py | 2 +- rslib/src/template.rs | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/pylib/tests/test_models.py b/pylib/tests/test_models.py index ebcc3d0fa..8209a3311 100644 --- a/pylib/tests/test_models.py +++ b/pylib/tests/test_models.py @@ -411,7 +411,7 @@ def test_req(): reqSize(opt) r = opt["req"][0] assert r[1] in ("any", "all") - assert r[2] == [0] + assert r[2] == [0, 1] # def test_updatereqs_performance(): diff --git a/rslib/src/template.rs b/rslib/src/template.rs index cfa4954f7..acdbff54d 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -285,12 +285,7 @@ fn template_is_empty<'a>(nonempty_fields: &HashSet<&str>, nodes: &[ParsedNode<'a match node { // ignore normal text Text(_) => (), - Replacement { key, filters } => { - // Anki doesn't consider a type: reference as a required field - if filters.contains(&"type") { - continue; - } - + Replacement { key, .. } => { if nonempty_fields.contains(*key) { // a single replacement is enough return false; @@ -657,7 +652,7 @@ mod test { let fields = HashSet::from_iter(vec!["1", "3"].into_iter()); let mut tmpl = PT::from_text("{{2}}{{1}}").unwrap(); assert_eq!(tmpl.renders_with_fields(&fields), true); - tmpl = PT::from_text("{{2}}{{type:cloze:1}}").unwrap(); + tmpl = PT::from_text("{{2}}").unwrap(); assert_eq!(tmpl.renders_with_fields(&fields), false); tmpl = PT::from_text("{{2}}{{4}}").unwrap(); assert_eq!(tmpl.renders_with_fields(&fields), false); @@ -700,12 +695,6 @@ mod test { FieldRequirements::All(HashSet::from_iter(vec![0, 1].into_iter())) ); - tmpl = PT::from_text("{{a}}{{type:b}}").unwrap(); - assert_eq!( - tmpl.requirements(&field_map), - FieldRequirements::Any(HashSet::from_iter(vec![0].into_iter())) - ); - tmpl = PT::from_text( r#" {{^a}}