https://github.com/python/cpython/commit/e396482f68cd830faa8af107b317b49830082a42 commit: e396482f68cd830faa8af107b317b49830082a42 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: terryjreedy <[email protected]> date: 2026-09-16T16:37:17Z summary:
[3.13] gh-60402: Fix Tab in a string in IDLE (GH-157593) (#157632) gh-60402: Fix Tab in a string in IDLE (GH-157593) Open the file name completion list only if some file name starts with the text before the cursor; otherwise insert a tab. If one wants the completion list, use Edit => Show completions. (cherry picked from commit 699e80265d2229e712d5f6adf6c3e9092e67fb6d) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Roger Serwy <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> files: A Misc/NEWS.d/next/IDLE/2026-09-15-21-44-35.gh-issue-60402.iFz6X6.rst M Lib/idlelib/autocomplete.py M Lib/idlelib/idle_test/test_autocomplete.py diff --git a/Lib/idlelib/autocomplete.py b/Lib/idlelib/autocomplete.py index 032d31225315fb..9cb809bc7d4646 100644 --- a/Lib/idlelib/autocomplete.py +++ b/Lib/idlelib/autocomplete.py @@ -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), diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index 88af3efc35bbd1..9086c31d2733b6 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -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) diff --git a/Misc/NEWS.d/next/IDLE/2026-09-15-21-44-35.gh-issue-60402.iFz6X6.rst b/Misc/NEWS.d/next/IDLE/2026-09-15-21-44-35.gh-issue-60402.iFz6X6.rst new file mode 100644 index 00000000000000..9b876ab0486f20 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2026-09-15-21-44-35.gh-issue-60402.iFz6X6.rst @@ -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. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
