Fix out of range after deletion in for loop

This commit is contained in:
Nick Perez
2023-03-13 06:21:25 -04:00
parent f761c4dafa
commit b4b24f1389

View File

@@ -1504,9 +1504,9 @@ class KoboldStoryRegister(object):
else: else:
self.actions[i]["Probabilities"][token_num][token_option]["Used"] = False self.actions[i]["Probabilities"][token_num][token_option]["Used"] = False
if "Options" in self.actions[i]: if "Options" in self.actions[i]:
for j in range(len(self.actions[i]["Options"])): for option in self.actions[i]["Options"][:]:
if self.actions[i]["Options"][j]["text"] == text: if option["text"] == text:
del self.actions[i]["Options"][j] self.actions[i]["Options"].remove(option)
if old_text != "": if old_text != "":
self.actions[i]["Options"].append({"text": old_text, "Pinned": False, "Previous Selection": False, "Edited": True}) self.actions[i]["Options"].append({"text": old_text, "Pinned": False, "Previous Selection": False, "Edited": True})
else: else: