Skip to content

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

Open
deadgander wants to merge 3 commits intoMohammadMD1383:masterfrom
deadgander:issue-105
Open

backstep end position to avoid duplicating last line when cursor at start of line#106
deadgander wants to merge 3 commits intoMohammadMD1383:masterfrom
deadgander:issue-105

Conversation

@deadgander
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

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

thanks

@deadgander
Copy link
Copy Markdown
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.

2 participants