SUMMARY Wrong auto indentation of C code STEPS TO REPRODUCE Take this snippet (which pass compilation) and select C code style in the bottom-right corner drop-down void test() {int a, b; char c; a = 0;b = 1; c = 'f';} void test2() {int a, b; a = 1;b = 3;} void main() { } Highlight the text then use Selection > Format Indentation OBSERVED RESULT Oddly, indentations are introduced like if the closing function bracket was not taken into account: void test() {int a, b; char c; a = 0;b = 1; c = 'f';} void test2() {int a, b; a = 1;b = 3;} void main() { } EXPECTED RESULT No extra indentation introduced (ie, the original indentation is kept) SOFTWARE/OS VERSIONS Operating System: Kubuntu 22.10 KDE Plasma Version: 5.25.5 KDE Frameworks Version: 5.98.0 Qt Version: 5.15.6 Kernel Version: 5.19.0-31-generic (64-bit) Graphics Platform: X11
This is somewhat complex for the built-in indenter to handle correctly. Please use our Format plugin instead which uses clang-format under the hood.
Yes, I am sorry that this will not work as intended, but the indenter is just some heuristics. For complex reformatting better use the format plugin. If you like to improve the indenter, the code is js, help is welcome https://invent.kde.org/frameworks/ktexteditor/-/blob/master/src/script/data/indentation/cstyle.js?ref_type=heads