Indent config: Soft Tabs: 4 (Indent using spaces) If you attempt to add an additional line before the next statement after a single-statement loop in a C source, autoindent indents the statement on the current line 3-levels too many. Example, save the following as a C-source (e.g. bug.c) while (whatever) printf ("please fix indentation.\n"); return 0; (make sure it has 4-spaces, a single level of indention before it in the file, e.g. select it and press ctrl+i) Now place the cursor at the insertion point immediately before the 'r' in 'return' (or at the beginning of the line) and press enter ('.' inserted to preserve spacing below): ....while (whatever) printf ("please fix indentation.\n"); ..............return 0; That is 14-spaces before 'return' instead of the expected `4`. The expected result is simply 4-spaces before each line with a blank line in between the commands. Moreover, `14` spaces??? That should never happen anyway with 'Soft Tabs: 4' set. Your indents are at 12 or 16, but never 14, something is borked. Now try and 'undo' (e.g. ctrl+z). You can't in one step. You have to undo twice. You should never have to 'undo' twice for the result of a single keystroke. One keystroke, one undo should restore to the previous state. Both of these make the indent model in kate/kwrite seems clumsy and broken. With more than a decade using kate/kwrite, these bugs were never present and the indent model in kde3. That indent model was very elegant and enjoyable to use for C, C++, php, html, etc.. There were never any surprises and it was rock-solid. The current indent model is more annoying than helpful in many circumstances. A slip of the finger attempting to insert a 'single-quote' that hits enter key and inserts a new line now takes '2 ctrl+z' to undo and restore the editor state. That's just broken and a symptom of fundamental problems with the current indent model. Is that a problem with KDE or Qt?
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/45
Git commit c82ba9d65a7eade8ff9fec291d55f44e05aac13b by Christoph Cullmann, on behalf of Waqar Ahmed. Committed on 13/12/2020 at 12:17. Pushed by cullmann into branch 'master'. Undo indent in one step Currently you have to press Ctrl+Z twice to undo an indent. With this commit, undo will happen in a single step. M +29 -0 autotests/src/undomanager_test.cpp M +1 -0 autotests/src/undomanager_test.h M +5 -0 src/document/katebuffer.cpp M +6 -0 src/document/katebuffer.h M +4 -2 src/document/katedocument.cpp https://invent.kde.org/frameworks/ktexteditor/commit/c82ba9d65a7eade8ff9fec291d55f44e05aac13b