diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2019-11-20 06:18:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 06:18:39 (GMT) |
commit | b8462477bfd01ff21461065d5063e6b0238ca809 (patch) | |
tree | 266c7a274d833dbc1d0cb8a3581375fc66305f4e | |
parent | 7483451577916e693af6d20cf520b2cc7e2174d2 (diff) | |
download | cpython-b8462477bfd01ff21461065d5063e6b0238ca809.zip cpython-b8462477bfd01ff21461065d5063e6b0238ca809.tar.gz cpython-b8462477bfd01ff21461065d5063e6b0238ca809.tar.bz2 |
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.
-rw-r--r-- | Lib/idlelib/NEWS.txt | 4 | ||||
-rw-r--r-- | Lib/idlelib/editor.py | 5 | ||||
-rw-r--r-- | Lib/idlelib/format.py | 3 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_format.py | 39 | ||||
-rw-r--r-- | Misc/NEWS.d/next/IDLE/2019-10-30-22-11-16.bpo-38636.hUhDeB.rst | 3 |
5 files changed, 48 insertions, 6 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index b02a988..c6aa00d 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -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. diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index dff104f..92dcf57 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -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) diff --git a/Lib/idlelib/format.py b/Lib/idlelib/format.py index bced4c1..2b09805 100644 --- a/Lib/idlelib/format.py +++ b/Lib/idlelib/format.py @@ -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): diff --git a/Lib/idlelib/idle_test/test_format.py b/Lib/idlelib/idle_test/test_format.py index c7b123e..20b5970 100644 --- a/Lib/idlelib/idle_test/test_format.py +++ b/Lib/idlelib/idle_test/test_format.py @@ -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() diff --git a/Misc/NEWS.d/next/IDLE/2019-10-30-22-11-16.bpo-38636.hUhDeB.rst b/Misc/NEWS.d/next/IDLE/2019-10-30-22-11-16.bpo-38636.hUhDeB.rst new file mode 100644 index 0000000..4262dbe --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2019-10-30-22-11-16.bpo-38636.hUhDeB.rst @@ -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. |