mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-33642: IDLE: Use variable number of lines in CodeContext. (GH-7106)
Instead of displaying a fixed number of lines, some blank, Code Context now displays the variable number of actual context lines. When there are no context lines, it shows a single blank line to indicate that the feature is turned on. The Code Context configuration option is changed from 'numlines' (default 3) to 'maxlines' (default 15) to avoid possible interference between user settings for the old and new versions of Code Context.
This commit is contained in:
parent
6854e803b7
commit
29996a1c4e
6 changed files with 40 additions and 29 deletions
|
@ -110,7 +110,7 @@ class CodeContextTest(unittest.TestCase):
|
|||
|
||||
def test_reload(self):
|
||||
codecontext.CodeContext.reload()
|
||||
self.assertEqual(self.cc.context_depth, 3)
|
||||
self.assertEqual(self.cc.context_depth, 15)
|
||||
|
||||
def test_toggle_code_context_event(self):
|
||||
eq = self.assertEqual
|
||||
|
@ -127,7 +127,7 @@ class CodeContextTest(unittest.TestCase):
|
|||
eq(cc.label['font'], cc.textfont)
|
||||
eq(cc.label['fg'], cc.fgcolor)
|
||||
eq(cc.label['bg'], cc.bgcolor)
|
||||
eq(cc.label['text'], '\n' * 2)
|
||||
eq(cc.label['text'], '')
|
||||
|
||||
# Toggle off.
|
||||
eq(toggle(), 'break')
|
||||
|
@ -193,24 +193,26 @@ class CodeContextTest(unittest.TestCase):
|
|||
eq(cc.info, [(0, -1, '', False)])
|
||||
eq(cc.topvisible, 1)
|
||||
|
||||
# Scroll down to line 1.
|
||||
cc.text.yview(1)
|
||||
cc.update_code_context()
|
||||
eq(cc.info, [(0, -1, '', False)])
|
||||
eq(cc.topvisible, 2)
|
||||
eq(cc.label['text'], '')
|
||||
|
||||
# Scroll down to line 2.
|
||||
cc.text.yview(2)
|
||||
cc.update_code_context()
|
||||
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
|
||||
eq(cc.topvisible, 3)
|
||||
# context_depth is 3 so it pads with blank lines.
|
||||
eq(cc.label['text'], '\n'
|
||||
'\n'
|
||||
'class C1():')
|
||||
eq(cc.label['text'], 'class C1():')
|
||||
|
||||
# Scroll down to line 3. Since it's a comment, nothing changes.
|
||||
cc.text.yview(3)
|
||||
cc.update_code_context()
|
||||
eq(cc.info, [(0, -1, '', False), (2, 0, 'class C1():', 'class')])
|
||||
eq(cc.topvisible, 4)
|
||||
eq(cc.label['text'], '\n'
|
||||
'\n'
|
||||
'class C1():')
|
||||
eq(cc.label['text'], 'class C1():')
|
||||
|
||||
# Scroll down to line 4.
|
||||
cc.text.yview(4)
|
||||
|
@ -219,8 +221,7 @@ class CodeContextTest(unittest.TestCase):
|
|||
(2, 0, 'class C1():', 'class'),
|
||||
(4, 4, ' def __init__(self, a, b):', 'def')])
|
||||
eq(cc.topvisible, 5)
|
||||
eq(cc.label['text'], '\n'
|
||||
'class C1():\n'
|
||||
eq(cc.label['text'], 'class C1():\n'
|
||||
' def __init__(self, a, b):')
|
||||
|
||||
# Scroll down to line 11. Last 'def' is removed.
|
||||
|
@ -232,7 +233,8 @@ class CodeContextTest(unittest.TestCase):
|
|||
(8, 8, ' if a > b:', 'if'),
|
||||
(10, 8, ' elif a < b:', 'elif')])
|
||||
eq(cc.topvisible, 12)
|
||||
eq(cc.label['text'], ' def compare(self):\n'
|
||||
eq(cc.label['text'], 'class C1():\n'
|
||||
' def compare(self):\n'
|
||||
' if a > b:\n'
|
||||
' elif a < b:')
|
||||
|
||||
|
@ -245,7 +247,8 @@ class CodeContextTest(unittest.TestCase):
|
|||
(8, 8, ' if a > b:', 'if'),
|
||||
(10, 8, ' elif a < b:', 'elif')])
|
||||
eq(cc.topvisible, 12)
|
||||
eq(cc.label['text'], ' def compare(self):\n'
|
||||
eq(cc.label['text'], 'class C1():\n'
|
||||
' def compare(self):\n'
|
||||
' if a > b:\n'
|
||||
' elif a < b:')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue