MohammadMD1383 / Actionable

Intellij plugin that adds many actions which are missing in the IDE!
https://mohammadmd1383.github.io/Actionable/
MIT License
15 stars 3 forks source link

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

Open deadgander opened 1 year ago

deadgander commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

thanks

deadgander commented 1 year ago

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.