[issue5124] IDLE - pasting text doesn't delete selection

Terry J. Reedy report at bugs.python.org
Fri Jun 3 14:57:15 EDT 2016


Terry J. Reedy added the comment:

Thank you David, that does help.  Your comment emphasizes that on other systems and many other X-11 apps, the user already chooses 'replace' versus 'insert' by selecting a replacement or not.   I presume the 'selection buffer' you refer to is different from the 'clipboard' (or whatever linux calls it).  Otherwise, Roger's patch would not work and I assume he tested it.

Simply applying Roger's patch, in 3.6, would be **MUCH** easier than adding a new option.  I could even add a line to the sign-on message: "Paste now replaces selected text.  Use undo to correct mistakes."

Assuming the patch does work, here is a workaround for releases that lack it. Create in Lib/idlelib a file called, for instance @MYPATCHES.txt and insert with the following, to remind what to do after upgrading to a new bugfix release.
---
To make paste replace selection, insert the following 3 lines at the top (after the def line) of EditorWindow.paste, about line 600, in file EditorWindow.py (3.5 and before) or editor.py (3.6 and after).

        sel = self.text.tag_ranges("sel")
        if sel:
            self.text.delete(*sel)   # issue5124
---

Save and then follow the instruction to patch the editor file. If doing the edit in IDLE, hit F5 to test the patched EditorWindow.

----------
versions: +Python 3.5, Python 3.6 -Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5124>
_______________________________________


More information about the Python-bugs-list mailing list