diff --git a/pylib/anki/tags.py b/pylib/anki/tags.py index 3302b8f9d..5ced38aa2 100644 --- a/pylib/anki/tags.py +++ b/pylib/anki/tags.py @@ -16,6 +16,7 @@ import re from typing import Collection, List, Optional, Sequence, Tuple import anki # pylint: disable=unused-import +from anki.rsbackend import FilterToSearchIn from anki.utils import ids2str @@ -86,11 +87,11 @@ class TagManager: def rename_tag(self, old: str, new: str) -> int: "Rename provided tag, returning number of changed notes." - escaped_name = re.sub(r"[*_\\]", r"\\\g<0>", old) - quote_escaped = escaped_name.replace('"', '\\"') - nids = self.col.find_notes(f'tag:"{quote_escaped}"') + search = self.col.backend.filter_to_search(FilterToSearchIn(tag=old)) + nids = self.col.find_notes(search) if not nids: return 0 + escaped_name = re.sub(r"[*_\\]", r"\\\g<0>", old) return self.bulk_update(nids, escaped_name, new, False) # legacy routines