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:43 | Assigned | |
---|---|---|---|
Priority | 5 | Labels | macros |
Status | open | Group | None |
Resolution | None |
2013-11-14 09:32:50 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.
|
---|---|
2013-11-14 23:03:41 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.
|
2013-11-15 09:41:49 kpouer |
I think it would not be user friendly.
|
2014-01-11 21:32:42.072000 daleanson |
I would argue otherwise. While other editors may do what this macro currently does,
previous invocations of this macro worked the way I described (I wrote the previous
version of this macro :)). Also, current behavior is inconsistent with other jEdit
actions, for example, if I do this:
|
2014-01-13 16:04:42.961000 snarum-micron |
If my cursor is on a line with nothing selected, I expect that line to be affected by any *_lines command. If I have selected any text, I expect all the lines with at least one selected character to be affected. But, if I have selected 1 full line and the cursor is in position 0 on the next line, I expect 1 and only 1 line to be affected. That is consistent behavior through most editors, and makes it easy to use. The move line macros and the TextTools Toggle Line Comment all do this wrong and take the line with the cursor as well. |
2014-01-13 16:06:51.845000 snarum-micron |
(I also expect my selection to not be altered for any of the three scenarios I listed above. The build-in Line Comment leaves me with nothing selected, which also is wrong, IMHO.) |