Skip to content

gh-94521: Copy or cut current line while no selection#145134

Open
znsoooo wants to merge 4 commits into
python:mainfrom
znsoooo:dev-copy-current-line-when-no-select
Open

gh-94521: Copy or cut current line while no selection#145134
znsoooo wants to merge 4 commits into
python:mainfrom
znsoooo:dev-copy-current-line-when-no-select

Conversation

@znsoooo

@znsoooo znsoooo commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

When the selection is empty, pressing Ctrl-C/Ctrl-X would copy text of zero length, which seems make no sense, and probably cause mistakes (e.g. forgot copy a zero-length text). Therefore, I modified the behavior to copy the current line when there is no selection, which supported by some other editors.

Comment thread Misc/NEWS.d/next/IDLE/2026-02-23-17-28-34.gh-issue-94521.vlr8XB.rst Outdated
…B.rst

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 7, 2026
Comment thread Lib/idlelib/editor.py

def cut(self,event):
if not self.text.tag_ranges('sel'):
self.text.tag_add('sel', 'insert linestart', 'insert+1l linestart')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work with multiple empty lines between 2 meaningful lines?
[and same comment for the copy action]

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants