Skip to content

Commit

Permalink
Restore the behavior which prints the maximal stem of all completions.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Dec 9, 2024
1 parent a428d77 commit 002a378
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions python/tkterminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,15 @@ def handle_tab(self, event):
return 'break'
if len(completions) == 1:
self.do_completion(stem, completions[0])
elif len(completions) > 60 and self.tab_count == 1:
else:
max_stem = self.max_stem(stem, completions)
if len(max_stem) > len(word):
self.do_completion(stem, max_stem)
return 'break'
if len(completions) > 60 and self.tab_count == 1:
self.show_completions('', '',
['%s possibilities -- hit tab again to view them all' %
len(completions)])
len(completions)])
else:
self.show_completions(word, stem, completions)
if len(completions) <= 60:
Expand Down Expand Up @@ -512,17 +517,17 @@ def clear_completions(self):
self.tab_index = None
self.tab_count = 0

def XXstem(self, wordlist):
if len(wordlist) == 1:
return wordlist[0]
result = ''
for n in range(1,100):
heads = {w[:n] for w in wordlist}
def max_stem(self, stem, completions):
if len(completions) == 1:
return completions[0]
result = stem
for n in range(len(stem) + 1, 100):
heads = {w[:n] for w in completions}
if len(heads) > 1:
return result
elif len(heads) == 1:
result = heads.pop()
return wordlist[0][:100]
return result

def write_continuation_prompt(self):
prompt_tokens = self._continuation_prompt(self._prompt_size)
Expand Down

0 comments on commit 002a378

Please sign in to comment.