Bug 309241

Summary: duplicateLinesUp and duplicateLinesDown fail if first line is in selection
Product: [Applications] kate Reporter: Gerald Senarclens de Grancy <oss>
Component: scriptingAssignee: KWrite Developers <kwrite-bugs-null>
Status: VERIFIED FIXED    
Severity: minor CC: i.zaufi
Priority: NOR    
Version: SVN   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Gerald Senarclens de Grancy 2012-10-30 09:36:59 UTC
Applying duplicateLinesUp and duplicateLinesDown does not work for the first line alone and for selections containing the first line.

reproduce:
- create a document with 4 lines and write a single number on each line (1 on the first, 2 on the second, ...)
- move the cursor to the beginning of the first line
- trigger duplicateLinesDown [Ctrl]+[Alt]+[down]

expected:
- the document now has an additional line inserted before the prior second line; the content of the line should be the same as the first line (1)

actual:
- an empty line is inserted before the prior first line

note:
- duplicateLinesUp doesn't do anything in the above scenario; 
- if the selection spans more than one lines (eg. Lines 1 and 2 are entirely selected), both duplicateLinesUp and duplicateLinesDown duplicate a single line: the line below the current selection
Comment 1 Christoph Cullmann 2012-11-09 19:31:36 UTC
Git commit 2627ac31573304bee5748d7043b97dee9439f46f by Christoph Cullmann.
Committed on 09/11/2012 at 20:31.
Pushed by cullmann into branch 'master'.

fix issue with duplicate line of first line in document

M  +2    -2    part/script/data/commands/utils.js

http://commits.kde.org/kate/2627ac31573304bee5748d7043b97dee9439f46f
Comment 2 Gerald Senarclens de Grancy 2012-11-11 12:05:26 UTC
Just verified Christoph's fix.
Comment 3 Dominik Haumann 2012-11-12 07:32:08 UTC
Gerald, are all issues with moveLineUp/Down and duplicateLineUp/Down now fixed? If not, please open another report, thanks!
Comment 4 Gerald Senarclens de Grancy 2012-11-12 08:25:18 UTC
Dominik, unfortunately, not everything is done yet. There are three issues left and I'll try to file proper bugs after work tonight. A short summary:
- http://commits.kde.org/kate/32da84eea27a461215624cc52da019392a08889e regresses moving to the last line.
- http://commits.kde.org/kate/32da84eea27a461215624cc52da019392a08889e also introduces a bug when moving after duplicating the first lines of a document
- I am aware of one last inconsistency when duplicating: if the cursor is in the beginning of an empty line below the selection, this line will be duplicated as well; this is inconsistent with non-empty lines

I hope to get around to create automatic tests for all of these asap.
Comment 5 Dominik Haumann 2012-11-12 09:01:13 UTC
@Alex: Can you have a look at comment #4, since these regressions were introduced by applying your patch :^) Would be cool if we can fix this again for KDE 4.10.