From 3bc25d44eea2043f1e9d131c1fcd0047ee9c16d7 Mon Sep 17 00:00:00 2001 From: Asmageddon Date: Sat, 26 May 2012 17:33:02 +0200 Subject: [PATCH] Fixed a crash bug introduced with inexact case matching --- deluge/ui/console/modes/legacy.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/deluge/ui/console/modes/legacy.py b/deluge/ui/console/modes/legacy.py index 4a6532904..e1901e2bd 100644 --- a/deluge/ui/console/modes/legacy.py +++ b/deluge/ui/console/modes/legacy.py @@ -87,7 +87,11 @@ def complete_line(line, possible_matches): for match in possible_matches[1:]: for i, c in enumerate(match): - if c.lower() != possible_matches[0][i].lower(): + try: + if c.lower() != possible_matches[0][i].lower(): + maxlen = min(maxlen, i) + break + except IndexError: maxlen = min(maxlen, i) break @@ -597,7 +601,11 @@ class Legacy(BaseMode): if hits == 1: p = " ".join(split(line)[:-1]) - l_arg = shlex.split(line)[-1] + try: + l_arg = shlex.split(line)[-1] + except IndexError: + l_arg = "" + new_line = " ".join( [p, complete_line(l_arg, possible_matches)] ).lstrip() if len(format_utils.remove_formatting(new_line)) > len(line):