mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-03 11:34:33 +12:00
Fixes a bug in #169: crash when moving around folders with the same name
This commit is contained in:
parent
c9fc18f685
commit
276559bc04
|
@ -569,9 +569,18 @@ def outlineItemPath(item):
|
||||||
else:
|
else:
|
||||||
# Count the number of siblings for padding '0'
|
# Count the number of siblings for padding '0'
|
||||||
siblings = item.parent().childCount()
|
siblings = item.parent().childCount()
|
||||||
|
|
||||||
|
# We check if multiple items have the same name
|
||||||
|
# If so, we add "-ID" to their name
|
||||||
|
siblingsNames = [s.title() for s in item.parent().children()]
|
||||||
|
if siblingsNames.count(item.title()) > 1:
|
||||||
|
title = "{}-{}".format(item.title(), item.ID())
|
||||||
|
else:
|
||||||
|
title = item.title()
|
||||||
|
|
||||||
name = "{ID}-{name}{ext}".format(
|
name = "{ID}-{name}{ext}".format(
|
||||||
ID=str(item.row()).zfill(len(str(siblings))),
|
ID=str(item.row()).zfill(len(str(siblings))),
|
||||||
name=slugify(item.title()),
|
name=slugify(title),
|
||||||
ext="" if item.type() == "folder" else ".md"
|
ext="" if item.type() == "folder" else ".md"
|
||||||
)
|
)
|
||||||
return outlineItemPath(item.parent()) + [name]
|
return outlineItemPath(item.parent()) + [name]
|
||||||
|
|
Loading…
Reference in a new issue