Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Copy/cut entire line if nothing is selected (Editor) #22480

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

The-Ludwig
Copy link

@The-Ludwig The-Ludwig commented Sep 10, 2024

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)
Kooha-2024-09-10-17-26-08.webm

This addition allows to copy and cut a whole line in the editor, with Ctr+C and Ctr+X as suggested in #21264.
This is similar to the behavior e.g. VSCode has.

Why select_current_line_and_sep is needed.

The most basic implementation is very straightforward (look after my first two commitss e08c076 and fdfd925). This PR is a bit longer, since we usually want to include the lineseperator from the current line, not the lineseperator from the previous line when copying/cutting whole lines. The exception there is if there is only one line or we are at the last line of the document.

Differences to standard editors like VSCode

This feature is already quite usable and improves my personal workflow greatly. To get exactly the same behavior as VSCode, CodeEditor.Paste needs to be modified. VSCode remembers if the clipboard was filled by not having anything selected and then selecting the whole line, and then on pasting inserts the line above the current line and adds the lineseperator at the end correctly.
I do not know what best-practise to save a state in this codebase is and the implementation of CodeEditor.Paste is a bit above my head right now. I need more experienced spyder developers to look at this in an upcoming PR.

Issue(s) Resolved

Fixes #21264

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct:
Ludwig Neste

@dalthviz dalthviz changed the title Copy/cut entire line if nothing is selected PR: Copy/cut entire line if nothing is selected (Editor) Sep 16, 2024
@dalthviz dalthviz added this to the v6.1.0 milestone Sep 16, 2024
@The-Ludwig
Copy link
Author

I do not understand why the fast linux tests pass, while the slow one don't. Any idea?

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.

Request: copy entire line with CTRL+C and no selection
2 participants