Actionable icon indicating copy to clipboard operation
Actionable copied to clipboard

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

Open deadgander opened this issue 2 years ago • 4 comments

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.

deadgander avatar Aug 01 '23 20:08 deadgander

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...

MohammadMD1383 avatar Aug 02 '23 04:08 MohammadMD1383

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.

deadgander avatar Aug 02 '23 06:08 deadgander

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

thanks

MohammadMD1383 avatar Aug 02 '23 07:08 MohammadMD1383

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.

deadgander avatar Aug 03 '23 21:08 deadgander