Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Lib/idlelib/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def open_completions(self, args):
comp_lists = self.fetch_completions(comp_what, mode)
if not comp_lists[0]:
return None
if (complete and mode == FILES
and not any(name.startswith(comp_start)
for name in comp_lists[0])):
return None
self.autocompletewindow = self._make_autocomplete_window()
return not self.autocompletewindow.show_window(
comp_lists, "insert-%dc" % len(comp_start),
Expand Down
6 changes: 6 additions & 0 deletions Lib/idlelib/idle_test/test_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ def make_acw(): return self.dummy_acw()
self.assertTrue(acp.open_completions(ac.TAB))
self.text.delete('1.0', 'end')

# No file name starts with the text (gh-60402).
self.text.insert('1.0', '"hello wor')
self.assertIsNone(acp.open_completions(ac.TAB))
self.assertTrue(acp.open_completions(ac.FORCE))
self.text.delete('1.0', 'end')

def test_completion_kwds(self):
self.assertIn('and', ac.completion_kwds)
self.assertIn('case', ac.completion_kwds)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In IDLE, Tab in a string that is not the start of a file name inserts a tab
instead of opening the completion list.
Loading