bpo-38636: Fix IDLE tab toggle and file indent width (GH-17008)

These Format menu functions (default shortcuts Alt-T and Alt-U)
were mistakenly disabled in 3.7.5 and 3.8.0.
This commit is contained in:
Terry Jan Reedy 2019-11-20 01:18:39 -05:00 committed by GitHub
parent 7483451577
commit b8462477bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 6 deletions

View File

@ -3,6 +3,10 @@ Released on 2020-10-05?
======================================
bpo-38636: Fix IDLE Format menu tab toggle and file indent width. These
functions (default shortcuts Alt-T and Alt-U) were mistakenly disabled
in 3.7.5 and 3.8.0.
bpo-4360: Add an option to toggle IDLE's cursor blink for shell,
editor, and output windows. See Settings, General, Window Preferences,
Cursor Blink. Patch by Zachary Spytz.

View File

@ -186,8 +186,9 @@ class EditorWindow(object):
text.bind("<<uncomment-region>>", fregion.uncomment_region_event)
text.bind("<<tabify-region>>", fregion.tabify_region_event)
text.bind("<<untabify-region>>", fregion.untabify_region_event)
text.bind("<<toggle-tabs>>", self.Indents.toggle_tabs_event)
text.bind("<<change-indentwidth>>", self.Indents.change_indentwidth_event)
indents = self.Indents(self)
text.bind("<<toggle-tabs>>", indents.toggle_tabs_event)
text.bind("<<change-indentwidth>>", indents.change_indentwidth_event)
text.bind("<Left>", self.move_at_edge_if_selection(0))
text.bind("<Right>", self.move_at_edge_if_selection(1))
text.bind("<<del-word-left>>", self.del_word_left)

View File

@ -353,8 +353,7 @@ class FormatRegion:
maxvalue=16)
# With mixed indents not allowed, these are semi-useless and not unittested.
class Indents: # pragma: no cover
class Indents:
"Change future indents."
def __init__(self, editwin):

View File

@ -417,7 +417,7 @@ class FormatRegionTest(unittest.TestCase):
self.text.delete('1.0', 'end')
code_sample = """\
# WS line needed for test.
class C1():
# Class comment.
def __init__(self, a, b):
@ -574,7 +574,42 @@ class C1():
self.assertEqual(ask(), 10)
class rstripTest(unittest.TestCase):
class IndentsTest(unittest.TestCase):
@mock.patch.object(ft, "askyesno")
def test_toggle_tabs(self, askyesno):
editor = DummyEditwin(None, None) # usetabs == False.
indents = ft.Indents(editor)
askyesno.return_value = True
indents.toggle_tabs_event(None)
self.assertEqual(editor.usetabs, True)
self.assertEqual(editor.indentwidth, 8)
indents.toggle_tabs_event(None)
self.assertEqual(editor.usetabs, False)
self.assertEqual(editor.indentwidth, 8)
@mock.patch.object(ft, "askinteger")
def test_change_indentwidth(self, askinteger):
editor = DummyEditwin(None, None) # indentwidth == 4.
indents = ft.Indents(editor)
askinteger.return_value = None
indents.change_indentwidth_event(None)
self.assertEqual(editor.indentwidth, 4)
askinteger.return_value = 3
indents.change_indentwidth_event(None)
self.assertEqual(editor.indentwidth, 3)
askinteger.return_value = 5
editor.usetabs = True
indents.change_indentwidth_event(None)
self.assertEqual(editor.indentwidth, 3)
class RstripTest(unittest.TestCase):
def test_rstrip_line(self):
editor = MockEditor()

View File

@ -0,0 +1,3 @@
Fix IDLE Format menu tab toggle and file indent width. These functions
(default shortcuts Alt-T and Alt-U) were mistakenly disabled in 3.7.5
and 3.8.0.