Allow for Code Style to add new line at end of constructor initialization list

Please add an option "Wrapping and Braces > Constructor initialization list > New line at end of list".

Here is an example function and class constructor for the existing code style.

void f(
int a
) {
bool z = true;
}

CLASS::CLASS (
int a
) {
bool z = true;
}

The issue is when an initializer list is used:

CLASS::CLASS (
  int a
) : SUPER_CLASS(a) {
  bool z = true;
}

It's difficult to differentiate between the body of the constructor and the initializer list. The way we format the code is to add a newline at the end of the constructor initialization list to enforce a clear break between it and the body:

CLASS::CLASS (
int a
) : SUPER_CLASS(a)
{
bool z = true;
}

Currently this is not possible with CLion's formatter. We don't want the opening brace to always be on a new line. We only want the addition of a new line at the the constructor initialization list.

We like the use of the code formatter but it is clobbering this newline and we don't know how to fix it when formatting files.

Please sign in to leave a comment.