PR: Copy/cut entire line if nothing is selected (Editor) #22480
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Kooha-2024-09-10-17-26-08.webm
This addition allows to copy and cut a whole line in the editor, with
Ctr+C
andCtr+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