diff options
author | 2021-08-23 21:16:48 +0200 | |
---|---|---|
committer | 2021-08-23 21:16:48 +0200 | |
commit | 0ead9a5e53548107d06ab8c69522359b9558061d (patch) | |
tree | 8c61a5be32b31312aeb55a1b54ce7a37122715bc | |
parent | remove redundant index assignments (diff) |
Fix tag fuzzy matching when searching against a longer target
-rw-r--r-- | bot/exts/info/tags.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bot/exts/info/tags.py b/bot/exts/info/tags.py index 520089e19..884c76ec4 100644 --- a/bot/exts/info/tags.py +++ b/bot/exts/info/tags.py @@ -120,9 +120,13 @@ def _fuzzy_search(search: str, target: str) -> float: current = 0 for _target in _targets: index = 0 - while index < len(_target) and _search[current] == _target[index]: - current += 1 - index += 1 + try: + while index < len(_target) and _search[current] == _target[index]: + current += 1 + index += 1 + except IndexError: + # Exit when _search runs out + break return current / len(_search) |