Skip to content

Commit

Permalink
normalize field before checking duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Aug 23, 2020
1 parent 4df89c7 commit 63b8b32
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions rslib/src/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
err::{AnkiError, Result},
notetype::{CardGenContext, NoteField, NoteType, NoteTypeID},
template::field_is_empty,
text::{ensure_string_in_nfc, strip_html_preserving_image_filenames},
text::{ensure_string_in_nfc, normalize_to_nfc, strip_html_preserving_image_filenames},
timestamp::TimestampSecs,
types::Usn,
};
Expand Down Expand Up @@ -424,7 +424,12 @@ impl Collection {

pub(crate) fn note_is_duplicate_or_empty(&self, note: &Note) -> Result<DuplicateState> {
if let Some(field1) = note.fields.get(0) {
let stripped = strip_html_preserving_image_filenames(field1);
let field1 = if self.normalize_note_text() {
normalize_to_nfc(field1)
} else {
field1.into()
};
let stripped = strip_html_preserving_image_filenames(&field1);
if stripped.trim().is_empty() {
Ok(DuplicateState::Empty)
} else {
Expand Down

0 comments on commit 63b8b32

Please sign in to comment.