mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -04:00
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.
This commit is contained in:
parent
d36bd33972
commit
4e33775ed4
2 changed files with 3 additions and 14 deletions
|
@ -411,7 +411,7 @@ def test_req():
|
||||||
reqSize(opt)
|
reqSize(opt)
|
||||||
r = opt["req"][0]
|
r = opt["req"][0]
|
||||||
assert r[1] in ("any", "all")
|
assert r[1] in ("any", "all")
|
||||||
assert r[2] == [0]
|
assert r[2] == [0, 1]
|
||||||
|
|
||||||
|
|
||||||
# def test_updatereqs_performance():
|
# def test_updatereqs_performance():
|
||||||
|
|
|
@ -285,12 +285,7 @@ fn template_is_empty<'a>(nonempty_fields: &HashSet<&str>, nodes: &[ParsedNode<'a
|
||||||
match node {
|
match node {
|
||||||
// ignore normal text
|
// ignore normal text
|
||||||
Text(_) => (),
|
Text(_) => (),
|
||||||
Replacement { key, filters } => {
|
Replacement { key, .. } => {
|
||||||
// Anki doesn't consider a type: reference as a required field
|
|
||||||
if filters.contains(&"type") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if nonempty_fields.contains(*key) {
|
if nonempty_fields.contains(*key) {
|
||||||
// a single replacement is enough
|
// a single replacement is enough
|
||||||
return false;
|
return false;
|
||||||
|
@ -657,7 +652,7 @@ mod test {
|
||||||
let fields = HashSet::from_iter(vec!["1", "3"].into_iter());
|
let fields = HashSet::from_iter(vec!["1", "3"].into_iter());
|
||||||
let mut tmpl = PT::from_text("{{2}}{{1}}").unwrap();
|
let mut tmpl = PT::from_text("{{2}}{{1}}").unwrap();
|
||||||
assert_eq!(tmpl.renders_with_fields(&fields), true);
|
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);
|
assert_eq!(tmpl.renders_with_fields(&fields), false);
|
||||||
tmpl = PT::from_text("{{2}}{{4}}").unwrap();
|
tmpl = PT::from_text("{{2}}{{4}}").unwrap();
|
||||||
assert_eq!(tmpl.renders_with_fields(&fields), false);
|
assert_eq!(tmpl.renders_with_fields(&fields), false);
|
||||||
|
@ -700,12 +695,6 @@ mod test {
|
||||||
FieldRequirements::All(HashSet::from_iter(vec![0, 1].into_iter()))
|
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(
|
tmpl = PT::from_text(
|
||||||
r#"
|
r#"
|
||||||
{{^a}}
|
{{^a}}
|
||||||
|
|
Loading…
Reference in a new issue