From d7583af6d0f0e1c331712241c3578882bd076cb8 Mon Sep 17 00:00:00 2001 From: Shixian Li Date: Mon, 23 Feb 2026 17:12:01 +0800 Subject: [PATCH 1/3] Feat: Copy or cut current line while no selection --- Lib/idlelib/editor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 3128934763a1c0..1e1e871b1bde3b 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -605,13 +605,16 @@ def python_docs(self, event=None): 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" def copy(self,event): if not self.text.tag_ranges("sel"): - # There is no selection, so do nothing and maybe interrupt. - return None + self.text.tag_add('sel', 'insert linestart', 'insert+1l linestart') + self.text.mark_set('insert', 'insert linestart') self.text.event_generate("<>") return "break" From 4c9463fa395acff7f902167d7b545572bbaaf217 Mon Sep 17 00:00:00 2001 From: Shixian Li Date: Mon, 23 Feb 2026 17:29:08 +0800 Subject: [PATCH 2/3] Docs: Add news --- .../next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst diff --git a/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst b/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst new file mode 100644 index 00000000000000..1d46b3a1a2ca94 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst @@ -0,0 +1 @@ +Copy or cut current line while no selection. Patch by Shixian Li. From 17db7cdd18a9208aa40338d794a382df4cbe435c Mon Sep 17 00:00:00 2001 From: Shixian Li Date: Tue, 24 Feb 2026 05:51:05 +0800 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst Co-authored-by: AN Long --- .../next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst b/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst index 1d46b3a1a2ca94..a32ab2c0526438 100644 --- a/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst +++ b/Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst @@ -1 +1 @@ -Copy or cut current line while no selection. Patch by Shixian Li. +Copy or cut the current line when no text is selected in IDLE. Patch by Shixian Li.