The move lines up and move lines down macros move too many lines and alters the selection.
To reproduce:
1. Open a buffer with several lines of text
2. Using the keyboard, move the caret to the start of the first line
3. Using the keyboard, select the first 2 lines (shift + down arrow twice). The caret
will now be on the start of the third line.
4. Run the move lines down macro. Notice the first 3 lines move, even though only
the first 2 lines were selected.
I expect only the 2 lines that I selected will be moved. Same issue with move lines
up.
Also, the selection is extended. To see this, paste this example text into a buffer:
// if nothing is selected, select current line
if (selection == null || selections.length == 0) {
selections = new Selection[1];
int start_offset = textArea.getLineStartOffset(line);
int end_offset = textArea.getLineEndOffset(line);
selections[0] = new Selection.Range(start_offset, end_offset);
textArea.addToSelection(selections[0]);
}
Same as above, use the keyboard (shift + down arrow twice) to select the first 2 lines.
The caret will be at the start of the third line, the whitespace before "selections
- new Selection[1]" is not selected. Run the move lines down macro. See that the 3rd
line moved and the whitespace at the start of the 3rd line is now selected.
Submitted | daleanson - 2013-09-19 - 18:32:43z | Assigned | nobody |
---|---|---|---|
Priority | 5 | Category | macros |
Status | Open | Group | None |
Resolution | None | Visibility | No |
2013-11-14 - 09:32:50z kpouer |
I don't understand, your selection starts from the beginning of the buffer and ends
on the third line, so it is logical that the third line is moved too. It is a "move lines" macro not a "move selection" macro. About the selection that is changed, yes this is a bug. In fact when moving lines, the lines are indented at their expected level. It works well if you select entire blocks or statements but if you select the beginning of a block it seems there are some problems. |
---|---|
2013-11-14 - 23:03:41z daleanson |
No, my selection is for just the first 2 lines. None of the third line is selected,
so I don't expect it to move. I agree this is to move lines, not a selection. If I
select from the middle of the first line through the middle of the third line, I would
expect all 3 lines to move. I would expect that if there is no selection at all, then
the line containing the caret would be the one to move. I guess this is an edge case, I'm expecting a selection from the start of the first line to the start of the third line to work the same as a selection from the start of the first line to the end of the second line. |
2013-11-15 - 09:41:49z kpouer |
I think it would not be user friendly. I tried a few editors: Eclipse does as you say, but break the selection after moving the caret. I think it is wrong. Notepad++ moves the 3 lines but extend the selection to all moved lines. IntelliJ Idea does exactly the same as jEdit. I still think that our choice is the best as it keeps the selection unchanged. |