Skip to content

Commit

Permalink
One more go at making completions work with the new IPython.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Dec 10, 2024
1 parent 002a378 commit 43b910a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions python/tkterminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,23 @@ def handle_tab(self, event):
if word.find('_') == -1:
completions = [x for x in completions
if x.find('__') == -1 and x.find('._') == -1]
if len(completions) == 0:
# No meaningful completions. Ring the bell.
if len(completions) == 0 or len(completions) == 1 and completions[0] == stem:
self.window.bell()
self.tab_count = 0
return 'break'
# Only one completion. Use it.
if len(completions) == 1:
self.do_completion(stem, completions[0])
else:
max_stem = self.max_stem(stem, completions)
if len(max_stem) > len(word):
self.do_completion(stem, max_stem)
return 'break'
self.tab_count = 0
return 'break'
max_stem = self.max_stem(stem, completions)
# Add the maximal stem of all completions if it extends the word,
if len(max_stem) > len(word):
self.do_completion(stem, max_stem)
self.tab_count = 0
return 'break'
# Show the possible completions, with a warning if there are lots.
if len(completions) > 60 and self.tab_count == 1:
self.show_completions('', '',
['%s possibilities -- hit tab again to view them all' %
Expand Down

0 comments on commit 43b910a

Please sign in to comment.