<div dir="ltr">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.<div><br></div><div>The issue seems to be related to this logic here in UnwrappedLineFormatter.cpp line ~831</div><div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><div>      <span style="color:rgb(0,0,255)">if</span> (Style.LambdaBodyIndentation == FormatStyle::LBI_OuterScope &&</div><div>          P.NestedBlockIndent == P.LastSpace) {</div><div></div></div></div><div><br></div><div>This is how the snippet gets formatted if there are return types:</div><div><br></div><div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(0,0,255)">return</span> someFunction(</div><div>    []() {</div><div>  someCode();</div><div>  <span style="color:rgb(0,0,255)">return</span> someOtherFunction(</div><div>      []() -><span style="color:rgb(0,0,255)"> </span>{</div><div>        someMoreCode();</div><div>        someMoreCode();</div><div>      },</div><div>      [] -><span style="color:rgb(0,0,255)"> </span>{</div><div>        someErrorHandlingCode();</div><div>        someErrorHandlingCode();</div><div>      });</div><div>    },</div><div>    [] -><span style="color:rgb(0,0,255)"> </span>{</div><div>      someErrorHandlingCode();</div><div>      someErrorHandlingCode();</div><div>    });</div><br></div></div><div>If I elide the return type on the lambdas I get:</div><div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(0,0,255)">return</span> someFunction(</div><div>    []() {</div><div>  someCode();</div><div>  <span style="color:rgb(0,0,255)">return</span> someOtherFunction(</div><div>      []() {</div><div>    someMoreCode();</div><div>    someMoreCode();</div><div>      },</div><div>      [] {</div><div>    someErrorHandlingCode();</div><div>    someErrorHandlingCode();</div><div>  });</div><div>    },</div><div>    [] {</div><div>  someErrorHandlingCode();</div><div>  someErrorHandlingCode();</div><div>});</div></div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre"><br></div>This is closer but still not quite what I want. The desired formatting should look like:</div><div><div style="line-height:19px"><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><span style="color:rgb(0,0,255)">return</span> someFunction(</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    []() {</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  someCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  <span style="color:rgb(0,0,255)">return</span> someOtherFunction(</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">      []() {</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    someMoreCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    someMoreCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  },</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">      [] {</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    someErrorHandlingCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    someErrorHandlingCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  });</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">},</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">    [] {</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  someErrorHandlingCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">  someErrorHandlingCode();</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">});</div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><br></div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small;white-space:normal">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:<br></span><div style="line-height:19px"><div><span style="color:rgb(0,0,255)">return</span> someFunction([]() {</div><div>  someCode();</div><div>  <span style="color:rgb(0,0,255)">return</span> someOtherFunction(</div><div>      []() {</div><div>    someMoreCode();</div><div>    someMoreCode();</div><div>  }, [] {</div><div>    someErrorHandlingCode();</div><div>    someErrorHandlingCode();</div><div>  });</div><div>}, [] {</div><div>  someErrorHandlingCode();</div><div>  someErrorHandlingCode();</div><div>});</div><br></div><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small;white-space:normal">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 </span><span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)">BeforeLambdaBody: false should do it according to the docs but it doesn't seem to</span><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small;white-space:normal">.</span></div><div style="color:rgb(0,0,0);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small;white-space:normal"><br></span></div><div style="">Thanks for any tips/pointers,</div><div style="">Vitali</div></div></div></div>