Skip to content

Commit

Permalink
fix: fix bug in pick_unique_name()
Browse files Browse the repository at this point in the history
  • Loading branch information
ntamas committed Sep 17, 2024
1 parent 69dbda2 commit 40b7765
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/modules/sbstudio/plugin/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,12 @@ def pick_unique_name(
return proposal

proposal = proposal.rstrip()
suffix = re.search("[0-9]*$", proposal)
if suffix is None:
return f"{proposal}.001"

suffix = suffix.group()
if not suffix:
return f"{proposal}.001"

prefix = proposal[: len(proposal) - len(suffix)]
match = re.search("[0-9]*$", proposal)
suffix = match.group() if match is not None else ""
if suffix:
prefix = proposal[: len(proposal) - len(suffix)]
else:
prefix, suffix = f"{proposal}.", "000"

value = int(suffix)
while True:
Expand Down

0 comments on commit 40b7765

Please sign in to comment.