<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59809>59809</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong indentation for designate initializer since clang-format-13
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chenhao94
</td>
</tr>
</table>
<pre>
Here are how to reproduce (default config)
```
# 12 looks good to me
chenhao@chenhao ~/format_test> clang-format-12 --version && echo --- && clang-format-12 1.cc
Ubuntu clang-format version 12.0.0-3ubuntu1~20.04.5
---
int main() {
auto looooooooong_var_name = 1;
auto s = {
.x = 1,
// some comments here.
.y = 2,
.z = 3,
};
return 0;
}
# 13: it is weird to push the items further with the assignment op, and it is weirder to misalign comments.
chenhao@chenhao ~/format_test> clang-format-13 --version && echo --- && clang-format-13 1.cc
Ubuntu clang-format version 13.0.1-++20220120110924+75e33f71c2da-1~exp1~20220120231001.58
---
int main() {
auto looooooooong_var_name = 1;
auto s = {
.x = 1,
// some comments here.
.y = 2,
.z = 3,
};
return 0;
}
# 14: comments are aligned with items, which is better than 13, but still not good to push the items so far.
chenhao@chenhao ~/format_test> clang-format-14 --version && echo --- && clang-format-14 1.cc
Ubuntu clang-format version 14.0.6
---
int main() {
auto looooooooong_var_name = 1;
auto s = {
.x = 1,
// some comments here.
.y = 2,
.z = 3,
};
return 0;
}
# 15 and 16(dev), same as 13.
chenhao@chenhao ~/format_test> clang-format-15 --version && echo --- && clang-format-15 1.cc
Ubuntu clang-format version 15.0.6
---
int main() {
auto looooooooong_var_name = 1;
auto s = {
.x = 1,
// some comments here.
.y = 2,
.z = 3,
};
return 0;
}
chenhao@chenhao ~/format_test> clang-format-16 --version && echo --- && clang-format-16 1.cc
Ubuntu clang-format version 16.0.0 (++20230103052724+ecb85b5cd89f-1~exp1~20230103172825.497)
---
int main() {
auto looooooooong_var_name = 1;
auto s = {
.x = 1,
// some comments here.
.y = 2,
.z = 3,
};
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUls1u4zYQx5-GvgwkkEN9HnTYJDX6AkWPASWNJbYSaZBUsruHPHtByXY-dlE4aQukgmFL5J9D0v-fOKO814Mhalh-w_K7nVrCaF3TjWRGZets19r-W_MrOQLlCEb7CMGCo6Oz_dIRMKx6OqhlCtBZc9ADw5rxO8a_nL4LfvpsjyhBIEzW_ulhsLaP0WbaOk-Tsoyf7uCJ4f5g3azCfSAfmPwFukmZIdkaE4GQJA_kvLYGGBYMC6ButJAkyfn57QCRdt0232_tYsLySgDnYAJTnvJELqtGPCFPeZbm28AkSbYbbQLMShuGFcMaWHmztYNago27PF1muH9Q7t6omYDJOxBMnpUAm9jDz64ofo6afj2Nxtvn0asM9wz34O1M0Nl5JhM8jOQofa1Lv60B8IcA6fe1Q77qYOXdq3U6CoszwC-NUfDS62iuZPIL6ADawyNptxp8XPwIYSTQgWYPh8WFkRw86rA1bxDGVYM9MrwFZfqXMcitmGivJj2Yyw7TD2Mj34uNvBYbmfJUJAxvGN4gR-QCuRC8xozhTZmTlIdSdNirRDzR12MEaxOhFJyLNK-uRewMzjspe03U31z_GLafBv0BwH-PvCySd1lQPK1WXKjfQFvZi3A9jrobI1sthRDRGlU0Lna1SwAf9DSBseFyPr3B11s4KPdx-LL3wpddC1-W8rT4vPx8VnDy9bwRxZrLHmICw1vw8V9QPr7RH3Y6f6_T-bVO5_-Z01cno_-v9R9wsnivk8W1ThaxzoDVs1POkFxwyXMs15xBXVvlbd71VX14kTNWkSixwjzN6vJSdX3G9_6Mz2di4FKX7vpG9rWs1Y4aUZRYVpLXYjc2UtUHLvO-63grhVB535YSs6oveZ-Xrdrp5uwDirwSIsW2rQ5VrXhRVHWVZyzjNCs9pdP0MKfWDTvt_UJNXle83k2qpcmvdTeioUdYOxliLMNdE8ck7TJ4lvFJ--CfowQdJmp-d9YMoE1PJqgQWTpYBz3FUkoFAm100GrS38mB16ajtyXNbnFTM4Zw9Ex-2cwZdBiXNu3szHAf5zv9JEdn_6AuMNyvq_QM9-su_goAAP__sYZeYQ">