Bugfix for text replacement optimization

This commit is contained in:
James Fitzgerald 2022-07-02 14:51:11 -04:00 committed by xs5871
parent 103e51eb7f
commit 81f4f7ccf0

View File

@ -49,7 +49,8 @@ class Phrase:
def next_character(self) -> None: def next_character(self) -> None:
"""Increment the current index for this phrase""" """Increment the current index for this phrase"""
self._index += 1 if not self.index_at_end():
self._index += 1
def get_character_at_current_index(self) -> Character: def get_character_at_current_index(self) -> Character:
"""Returns the character at the current index for this phrase""" """Returns the character at the current index for this phrase"""
@ -128,7 +129,9 @@ class TextReplacement(Module):
): ):
rule.to_substitute.next_character() rule.to_substitute.next_character()
rule.substitution.next_character() rule.substitution.next_character()
if rule.substitution.index_at_end(): else:
break
if rule.to_substitute.index_at_end():
break break
self._matched_rule = rule self._matched_rule = rule
self._state = State.DELETING self._state = State.DELETING