Fix uncrustify formatting for lambda expression

I would like to homogenize Qt Creator and uncrustify formatting for lambda expression.

Writing the following code with Qt Creator gives the following format:

connect(this, &MyObject::mySignal, [&] {
    qDebug() << "test lambda uncrustify formatting";
});

      

But when formatting the code with uncrustify, I have the following output:

connect(this, &MyObject::mySignal, [&] {
            qDebug() << "test lambda uncrustify formatting";
        });

      

Is there an uncrustify parameter that flattens the code like my Qt Creator example?

+3


source to share


2 answers


I finally managed to fix this with the latest version of uncrustify.



0


source


Maybe you are looking for indent_align_paren=false

? At least using this seems to give the expected results.

If it breaks non-lambdas ... so what does Qt Creator do?



// (A)
connect(this, &MyObject::mySignal,
    functor);

// (B)
connect(this, &MyObject::mySignal,
        functor);

      

If it gives you (B), it indent_align_paren=false

won't do what you want, and Qt Creator's formatting ... is questionable. (In this case, I suppose you should file a function request against uncrustify, or a bug report in Qt Creator.) If it gives you (A), then you want indent_align_paren=false

more than just lambda expressions.

0


source







All Articles