<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/153326>153326</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-format: comma in ternary breaks format
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          msftrncs
      </td>
    </tr>
</table>

<pre>
    clang-format version 20.1.7 (https://github.com/llvm/llvm-project.git 6146a88f60492b520a36f8f8f3231e15f3cc6082) (packaged with MS VS Code C++ extension for VS Code.

This formatting of comma's in ternary expressions has been an issue as long as I have been attempting to use the clang-format packaged in to the MS C++ extension for VS Code.  My max column setting is currently 132.  I could not identify any settings that would improve this.

C++ code prior to format,

``` c++
            FlowAccum_Frac = currFlowAccum > 60000U ? FlowAccum_Total += currFlowAccum / 60000U, currFlowAccum % 60000U
                                                    : currFlowAccum;
```

after format:

``` c++
            FlowAccum_Frac = currFlowAccum > 60000U ? FlowAccum_Total += currFlowAccum / 60000U,
 currFlowAccum % 60000U                  : currFlowAccum;
```

This seems like an incorrect behavior where the comma is not being considered to be in the middle of the ternary expression.   I have seen other places in code where it aligns with some other operator in a more complex expression where the ternary operator is deeper, such inside parenthesis, where I think its probably just aligning with the last opening parenthesis.

I usually resort to using parenthesis, which then formats as such:

``` c++
 FlowAccum_Frac = currFlowAccum > 60000U ? (FlowAccum_Total += currFlowAccum / 60000U, currFlowAccum % 60000U)
 : currFlowAccum;
```

I might have expected, at worst, if the maximum columns had been exceeded (lets say 100), to format as:

``` c++
            FlowAccum_Frac = currFlowAccum > 60000U ? FlowAccum_Total += currFlowAccum / 60000U,
 currFlowAccum % 60000U
 : currFlowAccum;
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVkGP4zYP_TXKhdhAlmPHOfiQmf0C5DCn2a_XQpZpWzuyZIhyJvn3heRk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