KDE 4.9.80 (KatePart 3.7?) When setting "Remove trailing spaces" to either "On Modified Lines" or "In Entire Document", trailing spaces are not removed in the current line before the cursor position. Reproducible: Always Steps to Reproduce: 1. Set "Remove trailing spaces" to "In Entire Document" 2. Add a few spaces at the end of a line in some document. 3. Position cursor at the end of the line or somwhere inside trailing spaces. 4 . Press Ctrl+S Actual Results: In the current line, only spaces in after the cursor are removed. For other lines, it works fine.
This is by design, see: http://quickgit.kde.org/?p=kate.git&a=commit&h=cebe2e4c47655d4fdef27ad4a306b89dfbdf3302 > only remove trailing spaces after cursor > This commit is dedicated to Milian, since he seems to have a spasm > in his left hand, such that he presses CTRL+S all the time (this > disease seems to be very widespread). The story is like this: > If you remove trailing spaces on save (either of all or only of > modified lines), and the cursor position is in the trailing spaces, > then the cursor jumps to the last character. The workaround is > that only trailing spaces after the cursor position are removed. > > This might leave trailing spaces in the saved document, so be > careful with your cursor navigation. > > Be warned: All bug reports for this will be assigned to you.
Exactly.
(I guess this "spasm" is just a joke for the habit of saving the document very often, right?) I don't believe this behaviour is preferred by the majority of users, it's inconsistent with other editors, too. Some checkbox like "Exclude current line" may be added for the current behaviour.
Yes, it's a joke. Having an option for such a simple thing sounds is imo over engineering. I'd prefer another workaround, if possible... the best solution would be to set the cursor position to an "invalid position" after the last character. but that's not possible currently.
Why is this not going to be fixed? This is very unusual behaviour. I was used to having the cursor move to the beginning of the line if the line is empty. I really dislike having to remember now to get to a blank line before saving.
I can see 2 ways to resolve this: 1. Remove trailing spaces in the saved document on disk but not the active workspace. OR 2. Add a checkbox to enable/disable the specific behaviour described above. Either way 'WONTFIX' definitely seems like the wrong option here.
Removing the trailing spaces just on disk won't work. Why? Because then, the document contents is different than the one on disk. And Kate uses the swap file mechanism: if the the system or kate crashes, then on startup, Kate looks whether a swap file exists. If so, it loads the swap file and replicates all edit actions in there. And replicating the edit actions relies on a synced contents, i.e. documents contents same as the contents of the file on disk. Changing the document contents behind Kate's back is therefore not a good idea and the very reason why it behaves this way right now.
*** Bug 350615 has been marked as a duplicate of this bug. ***
Git commit 9cf4f7a35d231774ce0a1f1c9def4f3272a5c845 by Dominik Haumann. Committed on 08/10/2015 at 21:27. Pushed by dhaumann into branch 'master'. fix bug #310712: remove trailing spaces also on line with cursor FIXED-IN: Frameworks 5.16 (Applications 15.12) CHANGELOG: fix bug #310712: remove trailing spaces also on line with cursor M +1 -12 src/document/katedocument.cpp http://commits.kde.org/ktexteditor/9cf4f7a35d231774ce0a1f1c9def4f3272a5c845
I think that killed one unittest see https://build.kde.org/job/ktexteditor%20master%20stable-kf5-qt5/112/
Git commit 7552ac73f55de0b383dd7904ad98eaf19dae0ae9 by Christoph Cullmann. Committed on 09/10/2015 at 12:16. Pushed by cullmann into branch 'master'. fix unit tests make unit tests resilent against trailing space stripping, better than turning it off for them M +1 -1 autotests/input/indent/pascal/label1/expected M +1 -0 autotests/input/indent/pascal/label1/input.js M +1 -1 autotests/input/indent/xml/opening1/expected M +1 -0 autotests/input/indent/xml/opening1/input.js M +1 -1 autotests/input/indent/xml/self_closing1/expected M +1 -0 autotests/input/indent/xml/self_closing1/input.js http://commits.kde.org/ktexteditor/7552ac73f55de0b383dd7904ad98eaf19dae0ae9