mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Add a warning when there is a cloze in "back extra" and "text" is empty (#3912)
* Add a warning when there is a cloze in "back extra" and "text" is empty Fix #3909 * Disallow non-blank first field card * Fix Rust ninja check
This commit is contained in:
parent
e546c6d11f
commit
1fa99c97e4
2 changed files with 17 additions and 14 deletions
|
@ -219,6 +219,7 @@ Jakub Fidler <jakub.fidler@protonmail.com>
|
||||||
Valerie Enfys <val@unidentified.systems>
|
Valerie Enfys <val@unidentified.systems>
|
||||||
Julien Chol <https://github.com/chel-ou>
|
Julien Chol <https://github.com/chel-ou>
|
||||||
ikkz <ylei.mk@gmail.com>
|
ikkz <ylei.mk@gmail.com>
|
||||||
|
rreemmii-dev <https://github.com/rreemmii-dev>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -594,7 +594,11 @@ impl Collection {
|
||||||
/// notetypes, check if there is a cloze in a non-cloze field or if there's
|
/// notetypes, check if there is a cloze in a non-cloze field or if there's
|
||||||
/// no cloze at all. For other notetypes, just check if there's a cloze.
|
/// no cloze at all. For other notetypes, just check if there's a cloze.
|
||||||
pub fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
|
pub fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
|
||||||
Ok(if let Some(text) = note.fields.first() {
|
Ok({
|
||||||
|
let cloze_state = self.field_cloze_check(note)?;
|
||||||
|
if cloze_state == NoteFieldsState::FieldNotCloze {
|
||||||
|
NoteFieldsState::FieldNotCloze
|
||||||
|
} else if let Some(text) = note.fields.first() {
|
||||||
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
|
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
|
||||||
normalize_to_nfc(text)
|
normalize_to_nfc(text)
|
||||||
} else {
|
} else {
|
||||||
|
@ -603,18 +607,16 @@ impl Collection {
|
||||||
let stripped = strip_html_preserving_media_filenames(&field1);
|
let stripped = strip_html_preserving_media_filenames(&field1);
|
||||||
if stripped.trim().is_empty() {
|
if stripped.trim().is_empty() {
|
||||||
NoteFieldsState::Empty
|
NoteFieldsState::Empty
|
||||||
} else {
|
} else if cloze_state != NoteFieldsState::Normal {
|
||||||
let cloze_state = self.field_cloze_check(note)?;
|
|
||||||
if cloze_state != NoteFieldsState::Normal {
|
|
||||||
cloze_state
|
cloze_state
|
||||||
} else if self.is_duplicate(&stripped, note)? {
|
} else if self.is_duplicate(&stripped, note)? {
|
||||||
NoteFieldsState::Duplicate
|
NoteFieldsState::Duplicate
|
||||||
} else {
|
} else {
|
||||||
NoteFieldsState::Normal
|
NoteFieldsState::Normal
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
NoteFieldsState::Empty
|
NoteFieldsState::Empty
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue