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

Multi-line cursor empty selections #7

Merged
merged 2 commits into from
May 1, 2024

Conversation

rcoopr
Copy link
Contributor

@rcoopr rcoopr commented Apr 30, 2024

In my early PR #6 I didn't consider multiline cursors. This expands any empty selections to the whole line's range, but only if that matches the default copy behaviour.

The code for getting the expanded selections has become a bit more involved specifically to cover the case where there are 2 or more selections on the same line and there is an empty selection after another selection (empty or not). In that case, the empty selection is ignored. If the empty selection is the first selection on a line, default copy behaviour copies the entire line, a line break, and then the proceeding selection.

For example (selections denoted via comment below the line):

Text to copy
^__^     ^

In this case, where the empty selection was placed after c, it will be ignored. The sorting of selections is required to cover the case where the empty selection at c was placed before the other selection

@mguellsegarra mguellsegarra self-assigned this May 1, 2024
@mguellsegarra
Copy link
Owner

@rcoopr you rock! Thank you so much for this contribution. Should be available in the next version.

@mguellsegarra mguellsegarra merged commit 66e2db6 into mguellsegarra:main May 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants