3

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

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

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

But when formatting the code with uncrustify I have the following result:

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

Is there an uncrustify option that align the code like my Qt Creator example?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Martin Delille
  • 11,360
  • 15
  • 65
  • 132

2 Answers2

0

Maybe you are looking for indent_align_paren=false? At least, using that seems to give the expected results.

If that breaks non-lambdas... well, which of these does Qt Creator give you?

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

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

If it gives you (B), then indent_align_paren=false will not do what you want, and Qt Creator's formatting is... questionable. (In which case, I suppose you should file a feature request against uncrustify, or a bug report against Qt Creator.) If it gives you (A), then you want indent_align_paren=false for more than just lambdas.

Matthew
  • 2,593
  • 22
  • 25
0

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

Martin Delille
  • 11,360
  • 15
  • 65
  • 132