diff --git a/src/wormhole/_rlcompleter.py b/src/wormhole/_rlcompleter.py index 5be03fa..a525a06 100644 --- a/src/wormhole/_rlcompleter.py +++ b/src/wormhole/_rlcompleter.py @@ -114,7 +114,7 @@ class CodeInputter(object): # improve the user experience. self.bcft(ih.when_wordlist_is_available) # blocks on CLAIM # and we're completing on words now - debug(" getting words") + debug(" getting words (%s)" % (words,)) completions = [nameplate+"-"+c for c in self.bcft(ih.get_word_completions, words)] diff --git a/src/wormhole/_wordlist.py b/src/wormhole/_wordlist.py index f966971..e14972b 100644 --- a/src/wormhole/_wordlist.py +++ b/src/wormhole/_wordlist.py @@ -172,7 +172,10 @@ class PGPWordList(object): completions = set() for word in words: if word.startswith(last_partial_word): - suffix = prefix[:-lp] + word + if lp == 0: + suffix = prefix + word + else: + suffix = prefix[:-lp] + word # append a hyphen if we expect more words if count+1 < num_words: suffix += "-" diff --git a/src/wormhole/test/test_wordlist.py b/src/wormhole/test/test_wordlist.py index b165fc3..6b86cdb 100644 --- a/src/wormhole/test/test_wordlist.py +++ b/src/wormhole/test/test_wordlist.py @@ -10,6 +10,10 @@ class Completions(unittest.TestCase): self.assertEqual(gc("ar", 2), {"armistice-", "article-"}) self.assertEqual(gc("armis", 2), {"armistice-"}) self.assertEqual(gc("armistice", 2), {"armistice-"}) + lots = gc("armistice-", 2) + self.assertEqual(len(lots), 256, lots) + first = list(lots)[0] + self.assert_(first.startswith("armistice-"), first) self.assertEqual(gc("armistice-ba", 2), {"armistice-baboon", "armistice-backfield", "armistice-backward", "armistice-banjo"})