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

backstep end position to avoid duplicating last line when cursor at start of line #106

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

Conversation

deadgander
Copy link

Move end position back one character to avoid last line being duplicated when the end cursor/selection position is at the start of the line.

This is to address issue 105.

@MohammadMD1383
Copy link
Owner

Hi, thanks for the PR.

but what if the caret is placed at the start of the line and no selection is made. this would cause the upper line being duplicated, also if this happens at offset 0 this may produce an exception...

@deadgander
Copy link
Author

deadgander commented Aug 2, 2023

The end is never less than start no matter which direction the selection is made. Therefore when the caret (end) is at offset 0, start will also be zero and it will not enter the branch that contains my change. When at the start of a line, start and end are the same so it also does not enter that branch.

However, I had seen an odd selection issue after performing Duplicate Lines Up, where it highlights the original and duplicated lines. I wrongly assumed this was not my fault but it did not happen before. I need to correct the caret and/or selection during the DUplicate Lines Up action.

@MohammadMD1383
Copy link
Owner

aha, looking forward to seeing the next updates...

thanks

@deadgander
Copy link
Author

I have updated both duplicateUp and duplicateDown to reset the caret position and selection after the text is inserted.

This is my first time working with Kotlin or contributing to an open soruce project so I hope it is okay.

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.

None yet

2 participants