mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	bpo-39885: Make IDLE context menu cut and copy work again (GH-18951)
Leave selection when right click within. This exception to clearing selections when right-clicking was omitted from the previous commit,4ca060d. I did not realize that this completely disabled the context menu entries, and I should have merged a minimal fix immediately. An automated test should follow. (cherry picked from commit97e4e0f53d) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
		
							parent
							
								
									805fa54676
								
							
						
					
					
						commit
						9f3f70fd0b
					
				
					 4 changed files with 52 additions and 16 deletions
				
			
		|  | @ -5,6 +5,7 @@ | |||
| from collections import namedtuple | ||||
| from test.support import requires | ||||
| from tkinter import Tk | ||||
| from idlelib.idle_test.mock_idle import Func | ||||
| 
 | ||||
| Editor = editor.EditorWindow | ||||
| 
 | ||||
|  | @ -92,6 +93,12 @@ def test_tabwidth_8(self): | |||
|                 ) | ||||
| 
 | ||||
| 
 | ||||
| def insert(text, string): | ||||
|     text.delete('1.0', 'end') | ||||
|     text.insert('end', string) | ||||
|     text.update()  # Force update for colorizer to finish. | ||||
| 
 | ||||
| 
 | ||||
| class IndentAndNewlineTest(unittest.TestCase): | ||||
| 
 | ||||
|     @classmethod | ||||
|  | @ -113,13 +120,6 @@ def tearDownClass(cls): | |||
|         cls.root.destroy() | ||||
|         del cls.root | ||||
| 
 | ||||
|     def insert(self, text): | ||||
|         t = self.window.text | ||||
|         t.delete('1.0', 'end') | ||||
|         t.insert('end', text) | ||||
|         # Force update for colorizer to finish. | ||||
|         t.update() | ||||
| 
 | ||||
|     def test_indent_and_newline_event(self): | ||||
|         eq = self.assertEqual | ||||
|         w = self.window | ||||
|  | @ -170,13 +170,13 @@ def test_indent_and_newline_event(self): | |||
|         w.prompt_last_line = '' | ||||
|         for test in tests: | ||||
|             with self.subTest(label=test.label): | ||||
|                 self.insert(test.text) | ||||
|                 insert(text, test.text) | ||||
|                 text.mark_set('insert', test.mark) | ||||
|                 nl(event=None) | ||||
|                 eq(get('1.0', 'end'), test.expected) | ||||
| 
 | ||||
|         # Selected text. | ||||
|         self.insert('  def f1(self, a, b):\n    return a + b') | ||||
|         insert(text, '  def f1(self, a, b):\n    return a + b') | ||||
|         text.tag_add('sel', '1.17', '1.end') | ||||
|         nl(None) | ||||
|         # Deletes selected text before adding new line. | ||||
|  | @ -184,11 +184,37 @@ def test_indent_and_newline_event(self): | |||
| 
 | ||||
|         # Preserves the whitespace in shell prompt. | ||||
|         w.prompt_last_line = '>>> ' | ||||
|         self.insert('>>> \t\ta =') | ||||
|         insert(text, '>>> \t\ta =') | ||||
|         text.mark_set('insert', '1.5') | ||||
|         nl(None) | ||||
|         eq(get('1.0', 'end'), '>>> \na =\n') | ||||
| 
 | ||||
| 
 | ||||
| class RMenuTest(unittest.TestCase): | ||||
| 
 | ||||
|     @classmethod | ||||
|     def setUpClass(cls): | ||||
|         requires('gui') | ||||
|         cls.root = Tk() | ||||
|         cls.root.withdraw() | ||||
|         cls.window = Editor(root=cls.root) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def tearDownClass(cls): | ||||
|         cls.window._close() | ||||
|         del cls.window | ||||
|         cls.root.update_idletasks() | ||||
|         for id in cls.root.tk.call('after', 'info'): | ||||
|             cls.root.after_cancel(id) | ||||
|         cls.root.destroy() | ||||
|         del cls.root | ||||
| 
 | ||||
|     class DummyRMenu: | ||||
|         def tk_popup(x, y): pass | ||||
| 
 | ||||
|     def test_rclick(self): | ||||
|         pass | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main(verbosity=2) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)