Looking for some help debugging LambdaBodyIndentation option

Hi, I’ve observed a few defects in LambdaBodyIndentation. I know I implemented this but I’m also not familiar with the codebase & I’ve spent some time without any forward progress investigating the issues. If anyone could be so kind as to help me figure out the problem I’d be very grateful.

The issue seems to be related to this logic here in UnwrappedLineFormatter.cpp line ~831

if (Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope &&
P.NestedBlockIndent == P.LastSpace) {

This is how the snippet gets formatted if there are return types:

return someFunction(
{
someCode();
return someOtherFunction(
→ {
someMoreCode();
someMoreCode();
},
→ {
someErrorHandlingCode();
someErrorHandlingCode();
});
},
→ {
someErrorHandlingCode();
someErrorHandlingCode();
});

If I elide the return type on the lambdas I get:

return someFunction(
{
someCode();
return someOtherFunction(
{
someMoreCode();
someMoreCode();
},
{
someErrorHandlingCode();
someErrorHandlingCode();
});
},
{
someErrorHandlingCode();
someErrorHandlingCode();
});

This is closer but still not quite what I want. The desired formatting should look like:

return someFunction(
{
someCode();
return someOtherFunction(
{
someMoreCode();
someMoreCode();
},
{
someErrorHandlingCode();
someErrorHandlingCode();
});
},
{
someErrorHandlingCode();
someErrorHandlingCode();
});

Actually I’d prefer the lambda be inline with the preceding lines if line width permits but I’m not sure why it seems to always be put on a new line:

return someFunction( {
someCode();
return someOtherFunction(
{
someMoreCode();
someMoreCode();
}, {
someErrorHandlingCode();
someErrorHandlingCode();
});
}, {
someErrorHandlingCode();
someErrorHandlingCode();
});

Probably unrelated to my changes though as stock clang format appears to put it on a newline & I can’t figure out how. In theory setting BeforeLambdaBody: false should do it according to the docs but it doesn’t seem to.

Thanks for any tips/pointers,
Vitali

It looks like the formatting for my e-mail may have been stripped. If that’s the case it should be possible to copy-paste the different lambdas into clang-format with --style=‘{LambdaBodyIndentation: OuterScope}’.

The last lambda of what I’m trying to get to can be found here: https://pastebin.com/eSGJnubw