Clang-format: how to prevent all function arguments in the next line?

I have a C ++ function call that I manually and intentionally formatted this:

DoSomethingForAPurposeThatCausesALongFunctionName(
    arg_0,
    arg_1,
    arg_2);

clang-format wants to reformat it like this:

DoSomethingForAPurposeThatCausesALongFunctionName(
    arg_0, arg_1, arg_2)

I do not want it. AllowAllParametersOfDeclarationOnNextLineappears, control this behavior for function declarations, but what about function calls? Is there an appropriate setting?

My .clang-formatlooks like this:

BasedOnStyle: Google
BinPackArguments: false
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: false
AlignAfterOpenBracket: AlwaysBreak
+5
source share
3 answers

The following configuration is correct to get the desired formatting with clang-format 5.0.

AlignAfterOpenBracket: AlwaysBreak
AllowAllParametersOfDeclarationOnNextLine: false
BinPackParameters: false
0
source

, , fun( . , , , fun(. , fun( .

, PenaltyBreakBeforeFirstCallParameter 100. , .

:

fun(my_long_argument_0,
    my_long_argument_1,
    my_long_argument_2);

, , DoSomethingForAPurposeThatCausesALongFunctionName(arg_0, , :

DoSomethingForAPurposeThatCausesALongFunctionName(
    arg_0,
    arg_1,
    arg_2);
0

,

AllowAllParametersOfDeclarationOnNextLine: true

, , , .

ExperimentalAutoDetectBinPacking: false

?

3.8.0.

-1
source

Source: https://habr.com/ru/post/1649393/


All Articles