Improve and unify `CopyLine`, `CutLine`, `DeleteLine`, `DuplicateLine` actions
- Clean up and unify behavior of the actions:
CopyandCutcopy or cut only the selection (and return false if there is no selection), whileCopyLineandCutLinecopy or cut the current line. - Add new
Duplicateaction which duplicates the selection only, and similarly clean up the actions behavior:Duplicateduplicates the selection (and returns false if there is no selection), whileDuplicateLineduplicates the current line. See #3110 - Correspondingly, update and unify the default keybindings:
current ones:
"Ctrl-c": "CopyLine|Copy",
"Ctrl-x": "Cut",
"Ctrl-d": "DuplicateLine",
changed to:
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-d": "Duplicate|DuplicateLine",
so the default behavior of these keys doesn't change.
-
Make
CopyLine,CutLine,DeleteLineandDuplicateLinerespect the selection (see #3328). When there is a multi-line selection, these actions should not just copy/cut/delete/duplicate the "current" line, as usual. This behavior is at least confusing, since when there is a selection, the cursor is not displayed, so the user doesn't know which line is the current one.So change the behavior of these actions: copy/cut/delete/duplicate all lines covered by the selection, not just the current line. Note that we cut/delete/copy/duplicate not just the selection itself (for that we have other actions:
Copy,Cutetc) but whole lines, i.e. if the first and/or the last line of the selection is only partially within the selection, we cut/delete/copy the entire first and last lines nonetheless.
- Various bugfixes and improvements.
Fixes #3328 Fixes #3110
Hi
I have had some thoughts about duplicate see https://github.com/zyedidia/micro/issues/3110. Mainly about leaving cursor position/selection unchanged - so we can repeat duplications as many times as necessary.
Kind Regards Gavin Holt
@JoeKar last time we agreed not to merge this before 2.0.14, to avoid changing keybindings semantics right before the release. Now that 2.0.14 has happened, shall we merge it?
And #3403 too (once we finish its review)?
I think there is a bug introduced in fdacb289624a5b6568571cc443e60b201ef5212f. The last line is selected only when CopyLine, CutLine or DeleteLine is done with no selection on the line even if it is not empty. I tried looking if I can fix it and I think BufPane.selectLines only will have to be changed when fixing it, but I do not know about the code structure and style much so I cannot easily come up with a good way to fix it.
Thanks, fixed in #3519.