cpython: 128ad410c776 (original) (raw)
Mercurial > cpython
changeset 102445:128ad410c776
Issue #19198: IDLE: tab after initial whitespace should tab, not autocomplete. Fixes problem with writing docstrings at lease twice indented. [#19198]
Terry Jan Reedy tjreedy@udel.edu | |
---|---|
date | Sun, 24 Jul 2016 23:01:28 -0400 |
parents | ab28676df655 |
children | 8f84942a0e40 |
files | Lib/idlelib/autocomplete.py Lib/idlelib/autocomplete_w.py Lib/idlelib/idle_test/test_autocomplete.py |
diffstat | 3 files changed, 12 insertions(+), 7 deletions(-)[+] [-] Lib/idlelib/autocomplete.py 9 Lib/idlelib/autocomplete_w.py 5 Lib/idlelib/idle_test/test_autocomplete.py 5 |
line wrap: on
line diff
--- a/Lib/idlelib/autocomplete.py +++ b/Lib/idlelib/autocomplete.py @@ -78,16 +78,17 @@ class AutoComplete: open a completion list after that (if there is more than one completion) """
if hasattr(event, "mc_state") and event.mc_state:[](#l1.7)
# A modifier was pressed along with the tab, continue as usual.[](#l1.8)
if hasattr(event, "mc_state") and event.mc_state or\[](#l1.9)
not self.text.get("insert linestart", "insert").strip():[](#l1.10)
# A modifier was pressed along with the tab or[](#l1.11)
# there is only previous whitespace on this line, so tab.[](#l1.12) return None[](#l1.13) if self.autocompletewindow and self.autocompletewindow.is_active():[](#l1.14) self.autocompletewindow.complete()[](#l1.15) return "break"[](#l1.16) else:[](#l1.17) opened = self.open_completions(False, True, True)[](#l1.18)
if opened:[](#l1.19)
return "break"[](#l1.20)
return "break" if opened else None[](#l1.21)
def _open_completions_later(self, *args): self._delayed_completion_index = self.text.index("insert")
--- a/Lib/idlelib/autocomplete_w.py +++ b/Lib/idlelib/autocomplete_w.py @@ -240,9 +240,8 @@ class AutoCompleteWindow: acw.wm_geometry("+%d+%d" % (new_x, new_y)) def hide_event(self, event):
if not self.is_active():[](#l2.7)
return[](#l2.8)
self.hide_window()[](#l2.9)
if self.is_active():[](#l2.10)
self.hide_window()[](#l2.11)
def listselect_event(self, event): if self.is_active():
--- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -97,6 +97,11 @@ class AutoCompleteTest(unittest.TestCase self.assertIsNone(autocomplete.autocomplete_event(ev)) del ev.mc_state
# Test that tab after whitespace is ignored.[](#l3.7)
self.text.insert('1.0', ' """Docstring.\n ')[](#l3.8)
self.assertIsNone(autocomplete.autocomplete_event(ev))[](#l3.9)
self.text.delete('1.0', 'end')[](#l3.10)
+ # If autocomplete window is open, complete() method is called self.text.insert('1.0', 're.') # This must call autocomplete._make_autocomplete_window()