Selecting one or more lines and then moving the lines w/ [ctrl]+[shift]+[up] (or [down]) affects a different range compared to duplicating (or indenting) these lines if the cursor is in the first column of the next line. A related (fixed) bug is 300649 though I believe it is not the same. Reproducible: Always Steps to Reproduce: 1. create a file with four distinguishable lines 2. position the cursor at the beginning of the second line 3. hold the shift button and press down once (=> the second line is selected and the cursor is at the beginning of the third line). 4. move ([ctrl]+[shift]+[down])/ duplicate ([ctrl]+[alt]+[down])/ indent the line Actual Results: move moves the selected line and the following line while duplicate and indent only affect the selected line Expected Results: consistent behavior (ie move only moves lines with at least one character selected) I currently use Kate 3.8.3 (which is not available as an <option> in the corresponding <select> field).
Gerald, can you quickly build Kate from sources according to http://kate-editor.org/get-it/ and tell us whether this is still an issue?
Hi Dominik, thx for having a look so quickly; the issue still reproduces with the minor difference that if first duplicating the position of the cursor is changed and the move affects the lines that are duplicated (as expected). The other way around (first moving and then duplicating or increasing the indentation) it's still inconsistent. Adjusting the move up/ move down script not to include a line if the cursor is at the beginning of a line when being at the end of the selection might be a nice fix. This should also fix 300649 as a side-effect (without having to change the cursor position).
Created attachment 73275 [details] Patch that checks the cursor position in relation to the selection I finally got around to fixing this myself. My proposed fix (attached patch to this bug) basically consists of checking if the end of the selected range is the first column. In addition, at the beginning of moveLinesDown I check if the selection ends in the first column of the last line. This is necessary in order to consistently allow moving lines to the last line. I tested the patch rather thoroughly, particularly to see if the behavior is now consistent with indentation and duplication which it is. Please let me know if I should send the patch to the mailinglist or discuss it on IRC (I use the nick "gerald" or "santa" or "geralds" in #kate). Thanks.
Thanks for the patch, Gerald. Can someone of the Kate developers commit this to master (4.10)?
Hello, I just checked out kate from git today to check whether another bug was still present and realized that this patch isn't yet included... so I was wondering if somethings wrong w/ it or if the devs just didn't get around to it. Thx.
Git commit 333f49886ecdc16aa2a45a4d569c5195bcdcfe2a by Christoph Cullmann. Committed on 24/10/2012 at 16:47. Pushed by cullmann into branch 'master'. commit patch by Gerald Senarclens de Grancy as requested by dh in bug 301162 fixes inconsistent behavior between move and duplicate line M +17 -0 part/script/data/utils.js http://commits.kde.org/kate/333f49886ecdc16aa2a45a4d569c5195bcdcfe2a
Grand, thx for the info. I'll probably pick up a few other junior jobs once I'll have some spare time and my RSI permits it.
In bug #302142, a similar patch was proposed. Now in order to get the best solution, can one of you guys hat a look at the other patch as well?
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 302142 REVIEW: 106867 M +46 -83 part/script/data/utils.js http://commits.kde.org/kate/32da84eea27a461215624cc52da019392a08889e
Dominik: I just tested your new commit and unfortunately it only works partly. - works: the correct line(s) are moved up and down, also after duplication - doesn't work: it is no longer possible to move a selection to the last line of the file (this wasn't possible before the two commits either, but was fixed by the first if block in https://projects.kde.org/projects/kde/kde-baseapps/kate/repository/revisions/333f49886ecdc16aa2a45a4d569c5195bcdcfe2a/diff/part/script/data/utils.js) Do you want me to open a new bug for the end of file issue? Btw - is there a suite of regression tests for utils.js? I could add some to avoid manual retesting...
@Alex: Can you have a look? @Gerald: In principal, yes: You need to create a unit test under kate/part/tests. There, you can call the script functions through the CommandLineInterface. If you are interested, I'd guide you through the process of writing this test. It requires some C++, but not much :-) Having a unit test would definitely fix this in the long run.
@Dominik: grand - just had a look at some existing tests and will likely get back on your offer once needed. The tests look rather straight forward (I've worked w/ googletest before which isn't too different). https://techbase.kde.org/Development/Tutorials/Unittests should be a good point to start - correct me if I'm wrong. I'll work on the test once I get the time to do so. Would you prefer to be contacted via irc/ mail/ ...? If possible I'd like anything w/out typing (gtalk?).
I'd say the best way to start is to start with http://kate-editor.org/get-it/ Once, you have a build, go to part/tests/ and look at some small unit test files (some bug, for example). Then copy one and register the new one in tests/CMakeLists.txt. Then you need to implement the logic: insert the text, call the moveLinesUp/Down functions and then check again whether everything looks as you expect... :) Contact: by mail on kwrite-devel@kde.org or in this bug report
Thx for the info. I have pulled & built kate again just before my last comment and ran the unit tests after having a look at some of them :) Thx for the hint w/ tests/CMakeLists.txt. I'll attach the test to this bug once it's done (but am a bit occupied atm, so it might take a little while).