mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Use new backend filters in rename_tag()
This commit is contained in:
parent
34245e6f72
commit
bf0086d565
1 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue