Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QoL: uniqueName function always returns a name with count starting from 2 #840

Open
DragRedSim opened this issue Jul 8, 2022 · 1 comment

Comments

@DragRedSim
Copy link

A small thing, but I was finding it really annoying when trying to write a definition.

unique_name = name
i = 1
while self.findContainersMetadata(id = unique_name, ignore_case = True) or self.findContainersMetadata(name = unique_name): #A container already has this name.
i += 1 #Try next numbering.
unique_name = "%s #%d" % (name, i) #Fill name like this: "Extruder #2".
return unique_name

Since the while loop adds one before the function generates a new name, if the loop is entered, it will never give a string with the value #1 at the end.

Fixed either by changing the initialisation on L718 to i = 0, or by swapping the order of lines 720 and 721; in this case, i will be raised after every test, but only compiled into the string with a new value if the first fails.

@nicholaslopiccolo
Copy link

Hello, thanks for opening the issue.
Did you open a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants