Index: AutoCompleteWindow.py =================================================================== --- AutoCompleteWindow.py (revision 60721) +++ AutoCompleteWindow.py (working copy) @@ -98,13 +98,17 @@ i = m + 1 last = i-1 + if first == last: # There is only one possible completion - return it + return self.completions[first] + # We should return the maximum prefix of first and last - i = len(s) - while len(self.completions[first]) > i and \ - len(self.completions[last]) > i and \ - self.completions[first][i] == self.completions[last][i]: + i = len(s) + 1 + first_comp = self.completions[first] + last_comp = self.completions[last] + min_len = min(len(first_comp), len(last_comp)) + while i < min_len and first_comp[i] == last_comp[i]: i += 1 - return self.completions[first][:i] + return first_comp[:i] def _selection_changed(self): """Should be called when the selection of the Listbox has changed.