bpo-33610: When toggling code-context on, immediately show the current context. by taleinat · Pull Request #14821 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Lib/idlelib/codecontext.py
17 changes: 14 additions & 3 deletions Lib/idlelib/idle_test/test_codecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_toggle_code_context_event(self):
toggle()

# Toggle on.
eq(toggle(), 'break')
toggle()
self.assertIsNotNone(cc.context)
eq(cc.context['font'], self.text['font'])
eq(cc.context['fg'], self.highlight_cfg['foreground'])
Expand All @@ -145,11 +145,22 @@ def test_toggle_code_context_event(self):
eq(self.root.tk.call('after', 'info', self.cc.t1)[1], 'timer')

# Toggle off.
eq(toggle(), 'break')
toggle()
self.assertIsNone(cc.context)
eq(cc.editwin.label, 'Show Code Context')
self.assertIsNone(self.cc.t1)

# Scroll down and toggle back on.
line11_context = '\n'.join(x[2] for x in cc.get_context(11)[0])
cc.text.yview(11)
toggle()
eq(cc.context.get('1.0', 'end-1c'), line11_context)

# Toggle off and on again.
toggle()
toggle()
eq(cc.context.get('1.0', 'end-1c'), line11_context)

def test_get_context(self):
eq = self.assertEqual
gc = self.cc.get_context
Expand Down Expand Up @@ -329,7 +340,7 @@ def test_font(self):
eq = self.assertEqual
cc = self.cc
save_font = cc.text['font']
test_font = 'TkFixedFont'
test_font = 'TkTextFont'

# Ensure code context is not active.
if cc.context is not None:
Expand Down