mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #19198: IDLE: tab after initial whitespace should tab, not autocomplete.
Fixes problem with writing docstrings at lease twice indented.
This commit is contained in:
parent
996d72bccf
commit
c665dfd73e
3 changed files with 12 additions and 7 deletions
|
@ -78,16 +78,17 @@ class AutoComplete:
|
||||||
open a completion list after that (if there is more than one
|
open a completion list after that (if there is more than one
|
||||||
completion)
|
completion)
|
||||||
"""
|
"""
|
||||||
if hasattr(event, "mc_state") and event.mc_state:
|
if hasattr(event, "mc_state") and event.mc_state or\
|
||||||
# A modifier was pressed along with the tab, continue as usual.
|
not self.text.get("insert linestart", "insert").strip():
|
||||||
|
# A modifier was pressed along with the tab or
|
||||||
|
# there is only previous whitespace on this line, so tab.
|
||||||
return None
|
return None
|
||||||
if self.autocompletewindow and self.autocompletewindow.is_active():
|
if self.autocompletewindow and self.autocompletewindow.is_active():
|
||||||
self.autocompletewindow.complete()
|
self.autocompletewindow.complete()
|
||||||
return "break"
|
return "break"
|
||||||
else:
|
else:
|
||||||
opened = self.open_completions(False, True, True)
|
opened = self.open_completions(False, True, True)
|
||||||
if opened:
|
return "break" if opened else None
|
||||||
return "break"
|
|
||||||
|
|
||||||
def _open_completions_later(self, *args):
|
def _open_completions_later(self, *args):
|
||||||
self._delayed_completion_index = self.text.index("insert")
|
self._delayed_completion_index = self.text.index("insert")
|
||||||
|
|
|
@ -240,8 +240,7 @@ class AutoCompleteWindow:
|
||||||
acw.wm_geometry("+%d+%d" % (new_x, new_y))
|
acw.wm_geometry("+%d+%d" % (new_x, new_y))
|
||||||
|
|
||||||
def hide_event(self, event):
|
def hide_event(self, event):
|
||||||
if not self.is_active():
|
if self.is_active():
|
||||||
return
|
|
||||||
self.hide_window()
|
self.hide_window()
|
||||||
|
|
||||||
def listselect_event(self, event):
|
def listselect_event(self, event):
|
||||||
|
|
|
@ -97,6 +97,11 @@ class AutoCompleteTest(unittest.TestCase):
|
||||||
self.assertIsNone(autocomplete.autocomplete_event(ev))
|
self.assertIsNone(autocomplete.autocomplete_event(ev))
|
||||||
del ev.mc_state
|
del ev.mc_state
|
||||||
|
|
||||||
|
# Test that tab after whitespace is ignored.
|
||||||
|
self.text.insert('1.0', ' """Docstring.\n ')
|
||||||
|
self.assertIsNone(autocomplete.autocomplete_event(ev))
|
||||||
|
self.text.delete('1.0', 'end')
|
||||||
|
|
||||||
# If autocomplete window is open, complete() method is called
|
# If autocomplete window is open, complete() method is called
|
||||||
self.text.insert('1.0', 're.')
|
self.text.insert('1.0', 're.')
|
||||||
# This must call autocomplete._make_autocomplete_window()
|
# This must call autocomplete._make_autocomplete_window()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue