Code::Blocks: 25.03
Platform: Windows
AStyle: 3.2 (bundled with Code::Blocks)
The AStyle “Preview” dialog box in “Settings->Editor…->Source formatter” produces the expected function argument indentation, but applying AStyle formatting to the actual source code produces different, incorrect argument indentation (it aligns all arguments on subsequent lines under the previous line’s first argument).
Expected results (shown correctly in Preview):
some_function(first_argument, second_argument, third_argument,
fourth_argument);
Actual results (after applying formatting to source code):
some_function(first_argument, second_argument, third_argument,
fourth_argument);
The “Indent after parens” option is enabled. "Word wrap" is off. "Line breaking..." is on and mine is set for 95 characters, but this doesn't seem to matter. Line breaks can be automatic or manual.
I believe the relevant settings are:
<INDENT_AFTER_PARENS bool="1" />
<CONTINUATION int="3" />
The problem occurs when formatting the actual source code with AStyle, which appears to indicate a difference between the AStyle settings applied by the Preview code and those applied by the normal editor-formatting code.
To Reproduce:
The actual source is formatted with the function arguments aligned under the previous argument instead of using the selected continuation indentation.
If you have questions are need clarification, please let me know.
BTW,
seems to be ignored. Normally, I have it set to 2, but I pasted the above before setting it back to normal.
As a work-a-round, I installed AStyle 3.6.18 and setup Code::Blocks to use it externally. My astylerc file looks like this:
and it formats correctly:
as opposed to:
Thanks for the IDE! I wish I'd discovered years ago.
We can update to Astyle 3.6.18, but it requires C++17 for the stupid string_view, and currently we keep C++11 compatibility. I will propose a global change to C++17 in the forum.