<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124057>124057</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang format: incorrect indentation of lambda inside nested function calls
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
malytomas
</td>
</tr>
</table>
<pre>
```c++
// correct / intended
const auto engineInitListener = controlThread().initialize.listen(
[]()
{
if (connectionState() == ConnectionStateEnum::None)
setScreenMainMenu();
},
99999);
// wrong
const auto escKeyPressListener = engineEvents().listen(inputFilter(
[](input::KeyPress in)
{
if (in.key != 256) // esc
return false;
if (escCallback)
{
escCallback();
return true;
}
return false;
}),
-1099);
```
The cause is the nested function call `inputFilter`. Without it the lambda is formatted correctly.
Note: github uses 8 spaces per tab, whereas the code uses 4 space per tab. clang-format tries to align the code with middle of `inputFilter` function.
```
# requires clang-format version 16 or later
---
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments:
Kind: Never
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakTemplateDeclarations: Yes
BasedOnStyle: Microsoft
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BreakBeforeBraces: Custom
ColumnLimit: 1000
Cpp11BracedListStyle: false
EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
Language: Cpp
LineEnding: DeriveLF
NamespaceIndentation: All
QualifierAlignment: Custom
QualifierOrder: ['friend', 'static', 'inline', 'constexpr', 'const', 'volatile', 'restrict', 'type']
ReflowComments: false
RequiresClausePosition: WithPreceding
SpaceAfterTemplateKeyword: false
SpaceInEmptyBlock: false
Standard: Latest
TabWidth: 4
UseTab: AlignWithSpaces
...
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykV0tv4roX_zRmY4GCKa8Fi0CL_tXQx3_oqLpLxz5JPHXsXNuB4X76K9skQGExnVtFKjnv8_N5ONRaUSiABRov0fi-RxtXarOoqDw4XVHbyzQ_LNAkiQ9DZOmfJEVkjcgaM20MMIf9b6EcKA4cJSnTyjpMG6cxqEIoeFTCbYR1oMBgNLrHTCtntHwrDVCOyAyR-UAo4QSV4h8YyCDr6UmKknmMLoodKdPl8UcyFzlGZMa0UsCc0GrrqIMo7H15d6tL5oNqKjRK0Sh91gpORsNjwW2ZAVBPVKgnUM3R76j1OL1HZBV_h78zZovL3mhVfALCsm9weDVg7QUSEaCHHShnj0B02QtVN24tpANzwuL3HtxhFozEbNsAsFCfkv4Ne2eI_64OxvFshBp8wAEjMvQZk_EkHE2ECiz7qt1o2oBrjMI5lRZOh_P14MCyFZUyo-zjq6D8IS5e7cLrZX39GQ7ONH8Igy_or2r9F_CPLsm8a6P-MDlvo3bcxJZ6KwEz2ljAwmJXAlZgHXCcNyp0NGZUSowmyXm3TJIBfheu1I3DwgU1SauMU28k16aizts4zi95GERfz9oBGqW4EK5sMtxYsHiGbU0ZWFyDwY5miKzwvgQDNIbDNIcoeRclW8EBZpKqoh_dYWcEWOw0plIU6qS6F67EleBcAtb5dSJdoscYL-AhI2zg70YYsJfedmCsB2c4wdpgSb2tJO33-yhJU8bA2ifNRS7AvOS5BT8gcP_OM310ae7AvNSgloayj8i918oFZiv0YBmtgT_DXgoF9qbMSw2GKn6b-WaokEIVK11VYfyNfH4YfxOKe4Vn2IWoUyn1fltq49ZHKOyLSrdCFRI2QoUTe1Q-iCC8pwe7NEA_3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