Skip to content

Commit 6482a12

Browse files
committed
Consider that a Match may not have any suggestions
1 parent 04966fc commit 6482a12

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎language_tool_python/match.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ def matchedText(self):
100100
def select_replacement(self, index: int) -> None:
101101
"""Choose one suggestion and delete the others. Usefull when you want to apply a specific suggestion.\n
102102
By default, the first suggestion is chosen."""
103-
if index < 0 or index >= len(self.replacements):
103+
if not self.replacements:
104+
raise ValueError('This Match has no suggestions')
105+
elif index < 0 or index >= len(self.replacements):
104106
raise ValueError('This Match\'s suggestions are numbered from 0 to {}'.format(len(self.replacements) - 1))
105107
self.replacements = [self.replacements[index]]
106108

0 commit comments

Comments
 (0)