Bug 302142 - [PATCH] after duplicating lines, moving the selected lines using shortcut also moves the line below them
Summary: [PATCH] after duplicating lines, moving the selected lines using shortcut als...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-18 18:17 UTC by Yuri
Modified: 2012-10-26 21:08 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to fix this problem (3.08 KB, patch)
2012-07-01 19:33 UTC, Tranquillity
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2012-06-18 18:17:21 UTC
After duplicating lines (usual shortcut Ctrl-Alt-Up/Down), both single (current) line and several (selected) lines, and moving the duplicated lines (which become selected) with the keyboard shortcut (Ctrl-Shift-Up/Down), not only the selection is moved, but also the line below it. This is not logical, because even the cursor is positioned at the first line of the selection. Due to this bug, the shortcuts to duplicate and then move lines are unusable.
This behavior does not appear when moving the selected lines with mouse, and in versions prior to KDE 4.8.3 (which has appeared in FreeBSD ports very recently; the last version before that was KDE 4.7.4) it worked as expected.

Reproducible: Always

Steps to Reproduce:
1. Optionally, select several lines
2. Press Ctrl-Alt-Up/Down to duplicate the selection (or, if none, the line under cursor)
3. Press Ctrl-Shift-Up/Down to move the duplicated line(s)
Actual Results:  
the line below the duplicated line(s) is moved along these lines. 

Expected Results:  
only the duplicated line(s) should be moved
Comment 1 Tranquillity 2012-06-28 18:01:14 UTC
I stumbled upon this not exactly in the same context as Yuri (saw it without duplicating lines before). But I have the core problem after updating my Debian unstable from a 4.7.x version to 4.8.4 too.

Looks like a regression for me since earlier versions already had this less intuitive behavior in the past.

I guess the logic for the current behavior is that the selection really extends to the beginning of the next line (no matter if the cursor is positioned at the beginning or the end of this selection).

The rules I would like more (and how it worked in 4.7) look like this:
- If there is no selection move the line with the cursor in it
- If there is a selection move only the lines where the selection is visible (lines where at least one character is selected)

If we do not count the line break to the following line there really is nothing selected in it even if the cursor is positioned at the beginning of that line.
Comment 2 Tranquillity 2012-07-01 19:33:27 UTC
Created attachment 72262 [details]
Patch to fix this problem

Maybe a maintainer can review this patch.

move lines up/down: do not move line with no visible selection
    
- subtle change came with revision 540aa847218b037cda5ad4a52498dae30d83eea2
- also handles movement down to the end of the file
Comment 3 Bauke 2012-09-18 12:32:50 UTC
This problem also affects me on Ubuntu 12.04. However, I could apply the patch to my binary installation and its working fine. Thanks. I hope that the patch is merged in soon.
Comment 4 Dominik Haumann 2012-10-24 22:38:14 UTC
Ok, now another similar patch was just committed into what will become KDE 4.10.
The applied patch can be found in bug #301162. Can you please test whether the behavior already works as you expect it to?
Comment 5 Dominik Haumann 2012-10-26 21:08:18 UTC
Git commit 32da84eea27a461215624cc52da019392a08889e by Dominik Haumann.
Committed on 26/10/2012 at 23:08.
Pushed by dhaumann into branch 'master'.

simplify moveLinesUp/Down

All you guys having put time into fixing this: Can you please test this
implementation again? Thanks!!!
Related: bug 301162
REVIEW: 106867

M  +46   -83   part/script/data/utils.js

http://commits.kde.org/kate/32da84eea27a461215624cc52da019392a08889e