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

Do not include last line in Duplicate Lines Down when cursor at start of line #105

Open deadgander opened 1 year ago

deadgander commented 1 year ago

Duplicate Lines Down behaves slightly differently to other editors (Eclipse, VS Code) in a way that seems strange.

Given the example text:

abc def ghi jkl

To duplicate the middle two lines, I would position the cursor at the start of abc and then *shift+down twice to highlight abc and ghi. The cursor is positioned at the start (left) of jkl. Performing Duplicate Lines Down at this point will duplicate def, ghi and jkl. Other editors tend to not duplicate the last line when the cursor is at the start of the line.

I have locally changed DuplicateAction.kt, adding - 1 to the endLine. endingLine = document.getLineNumber(end - 1)

This seems to sort it but I haven't fully tested it (selecting from down to up, or performing Duplicate Lines Up).

Could this be changed or made configurable?

As an aside, this plug-in was recommend to me by Jet Brains as not having Duplicate Lines Up was stopping me from moving to their IDEs. Thank you for this plug-in.

MohammadMD1383 commented 1 year ago

Hi, thanks for filling out this issue. You're right, I will try to fix it as soon as I can, but till then if you could fix it, I would be happy to merge your PR!

And I'm glad that my plugin could help someone... !