Assign dupe error the lowest precedence

This commit is contained in:
RumovZ 2021-06-16 11:42:40 +02:00
parent 0f549d2b82
commit 87a50f22e6

View file

@ -534,7 +534,7 @@ impl Collection {
/// 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.
pub(crate) fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
if let Some(text) = note.fields.get(0) {
Ok(if let Some(text) = note.fields.get(0) {
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
normalize_to_nfc(text)
} else {
@ -542,15 +542,20 @@ impl Collection {
};
let stripped = strip_html_preserving_media_filenames(&field1);
if stripped.trim().is_empty() {
Ok(NoteFieldsState::Empty)
NoteFieldsState::Empty
} else {
let cloze_state = self.field_cloze_check(note)?;
if cloze_state != NoteFieldsState::Normal {
cloze_state
} else if self.is_duplicate(&stripped, note)? {
Ok(NoteFieldsState::Duplicate)
NoteFieldsState::Duplicate
} else {
self.field_cloze_check(note)
NoteFieldsState::Normal
}
}
} else {
Ok(NoteFieldsState::Empty)
}
NoteFieldsState::Empty
})
}
fn is_duplicate(&self, first_field: &str, note: &Note) -> Result<bool> {