mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Escape backslashes in re.sub()'s repl
This commit is contained in:
parent
c0d77896da
commit
e2940de4a4
1 changed files with 9 additions and 2 deletions
|
@ -66,7 +66,12 @@ class SidebarItemType(Enum):
|
||||||
return self in self.section_roots()
|
return self in self.section_roots()
|
||||||
|
|
||||||
def is_editable(self) -> bool:
|
def is_editable(self) -> bool:
|
||||||
return self in (SidebarItemType.SAVED_SEARCH, SidebarItemType.DECK, SidebarItemType.TAG)
|
return self in (
|
||||||
|
SidebarItemType.SAVED_SEARCH,
|
||||||
|
SidebarItemType.DECK,
|
||||||
|
SidebarItemType.TAG,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SidebarStage(Enum):
|
class SidebarStage(Enum):
|
||||||
ROOT = auto()
|
ROOT = auto()
|
||||||
|
@ -1187,7 +1192,9 @@ class SidebarTreeView(QTreeView):
|
||||||
|
|
||||||
def rename_node(self, item: SidebarItem, text: str) -> bool:
|
def rename_node(self, item: SidebarItem, text: str) -> bool:
|
||||||
if text.replace('"', ""):
|
if text.replace('"', ""):
|
||||||
new_name = re.sub(re.escape(item.name) + "$", text, item.full_name)
|
new_name = re.sub(
|
||||||
|
re.escape(item.name) + "$", text.replace("\\", r"\\"), item.full_name
|
||||||
|
)
|
||||||
if item.item_type == SidebarItemType.DECK:
|
if item.item_type == SidebarItemType.DECK:
|
||||||
self.rename_deck(item, new_name)
|
self.rename_deck(item, new_name)
|
||||||
if item.item_type == SidebarItemType.SAVED_SEARCH:
|
if item.item_type == SidebarItemType.SAVED_SEARCH:
|
||||||
|
|
Loading…
Reference in a new issue