Fixed a crash bug introduced with inexact case matching

This commit is contained in:
Asmageddon 2012-05-26 17:33:02 +02:00
parent ba7e36c719
commit 3bc25d44ee
1 changed files with 10 additions and 2 deletions

View File

@ -87,9 +87,13 @@ def complete_line(line, possible_matches):
for match in possible_matches[1:]: for match in possible_matches[1:]:
for i, c in enumerate(match): for i, c in enumerate(match):
try:
if c.lower() != possible_matches[0][i].lower(): if c.lower() != possible_matches[0][i].lower():
maxlen = min(maxlen, i) maxlen = min(maxlen, i)
break break
except IndexError:
maxlen = min(maxlen, i)
break
return possible_matches[0][:maxlen].replace(" ", r"\ ") return possible_matches[0][:maxlen].replace(" ", r"\ ")
@ -597,7 +601,11 @@ class Legacy(BaseMode):
if hits == 1: if hits == 1:
p = " ".join(split(line)[:-1]) p = " ".join(split(line)[:-1])
try:
l_arg = shlex.split(line)[-1] l_arg = shlex.split(line)[-1]
except IndexError:
l_arg = ""
new_line = " ".join( [p, complete_line(l_arg, possible_matches)] ).lstrip() new_line = " ".join( [p, complete_line(l_arg, possible_matches)] ).lstrip()
if len(format_utils.remove_formatting(new_line)) > len(line): if len(format_utils.remove_formatting(new_line)) > len(line):