From ff170bff3132e9a3a796207f4bd09b7c2d3d94c8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 30 Apr 2020 08:54:17 +1000 Subject: [PATCH] fix tags with missing leading/trailing spaces in DB check --- pylib/anki/collection.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index cacef5f3e..2df64a6f9 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -1009,9 +1009,11 @@ and type=0""", def _normalize_tags(self) -> int: to_fix = [] for id, tags in self.db.execute("select id, tags from notes"): - nfc = unicodedata.normalize("NFC", tags) - if nfc != tags: - to_fix.append((nfc, self.usn(), intTime(), id)) + norm = unicodedata.normalize("NFC", tags) + if not norm.startswith(" ") or not norm.endswith(" "): + norm = " " + norm + " " + if norm != tags: + to_fix.append((norm, self.usn(), intTime(), id)) if to_fix: self.db.executemany( "update notes set tags=?, usn=?, mod=? where id=?", to_fix