Better handle multimatch index out of scope. Resolve #2207.
This commit is contained in:
parent
aac9eb17d9
commit
5f8911ec72
4 changed files with 15 additions and 9 deletions
|
|
@ -209,10 +209,15 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
|
|||
quality = [mat[4] for mat in matches]
|
||||
matches = matches[-quality.count(quality[-1]) :]
|
||||
|
||||
if len(matches) > 1 and match_index is not None and 0 < match_index <= len(matches):
|
||||
if len(matches) > 1 and match_index is not None:
|
||||
# We couldn't separate match by quality, but we have an
|
||||
# index argument to tell us which match to use.
|
||||
matches = [matches[match_index - 1]]
|
||||
if 0 < match_index <= len(matches):
|
||||
matches = [matches[match_index - 1]]
|
||||
else:
|
||||
# we tried to give an index outside of the range - this means
|
||||
# a no-match
|
||||
matches = []
|
||||
|
||||
# no matter what we have at this point, we have to return it.
|
||||
return matches
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue