diff --git a/Lib/idlelib/News3.txt b/Lib/idlelib/News3.txt index bcbd7fa542a02a4..5f84d749311863d 100644 --- a/Lib/idlelib/News3.txt +++ b/Lib/idlelib/News3.txt @@ -3,6 +3,8 @@ What's New in IDLE 3.15.0 Released on 2026-10-01 ========================= +gh-94521: If no selection is made during copy/cut, the current line +will copy/cut automatically. gh-152745: When "Run... Customized" with "Restart shell" unchecked while Shell is running code, including waiting for an input('prompt:') diff --git a/Lib/idlelib/iomenu.py b/Lib/idlelib/iomenu.py index 9560aaa2da0c424..c44afe2a6e46bfd 100644 --- a/Lib/idlelib/iomenu.py +++ b/Lib/idlelib/iomenu.py @@ -33,6 +33,8 @@ def __init__(self, editwin): self.save_a_copy) self.fileencoding = 'utf-8' self.__id_print = self.text.bind("<>", self.print_window) + self.__id_copy = self.text.bind("<>", self.copy) + self.__id_cut = self.text.bind("<>", self.cut) def close(self): # Undo command bindings @@ -41,6 +43,8 @@ def close(self): self.text.unbind("<>",self.__id_saveas) self.text.unbind("<>", self.__id_savecopy) self.text.unbind("<>", self.__id_print) + self.text.unbind("<>", self.__id_copy) + self.text.unbind("<>", self.__id_cut) # Break cycles self.editwin = None self.text = None @@ -375,6 +379,20 @@ def print_window(self, event): os.unlink(tempfilename) return "break" + def copy(self, event): + if not self.text.tag_ranges("sel"): + self.text.tag_add("sel", "insert linestart", "insert+1l linestart") + self.text.mark_set("insert", "insert linestart") + self.text.event_generate("<>") + return "break" + + def cut(self, event): + if not self.text.tag_ranges("sel"): + self.text.tag_add("sel", "insert linestart", "insert+1l linestart") + self.text.mark_set("insert", "insert linestart") + self.text.event_generate("<>") + return "break" + opendialog = None savedialog = None diff --git a/Misc/NEWS.d/next/IDLE/2024-10-27-20-17-54.gh-issue-94521.XEFTrz.rst b/Misc/NEWS.d/next/IDLE/2024-10-27-20-17-54.gh-issue-94521.XEFTrz.rst new file mode 100644 index 000000000000000..119f09c69222d77 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2024-10-27-20-17-54.gh-issue-94521.XEFTrz.rst @@ -0,0 +1,2 @@ +If no selection is made during copy/cut, the current line will copy/cut +automatically.