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

    <tr>
        <th>Summary</th>
        <td>
            C# formatter sometimes fails with complicated lambda
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          3geek14
      </td>
    </tr>
</table>

<pre>
    Using clang-format to format C# files, I'm getting a weird error where it removes some levels of indentation, causing the file to end with several vertically-aligned `}`s.

Invocation:
```path\to\clang-format.exe -style=LLVM Program.cs```
Program.cs:
```
using System;
using System.Threading;

namespace MinimalWorkingExample {
  public class Program {
    public static void Main(string[] args) {
      var thread = new Thread(() =>
      {
        try
        {
          var x = 0;
        } catch {
          Console.WriteLine("This compiles.");
        }
      });
    }
  }
}

```
Console output:
```
using System;
using System.Threading;

namespace MyFirstProject {
public class Program {
  public static void Main(string[] args) {
      var thread = new Thread(() =>
      {
        try
        {
          var x = 0;
  }
  catch {
    Console.WriteLine("This compiles.");
  }
});
}
}
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVE1v2zAM_TX2hYjh-COZDz6sSQsUaIEB69azbDO2VtkyJDpp_v0oO81Hm2LAgB0GGLJEPZJPfAQLXe3zH1Z2NZRKdPVso00rCEjDYbfyohg2UqH1ohXce9GyhRqJnIuAHUpTARqjDewaNAiSwGCrt2jB6hZB4RaVBb0B2VXYkSCpOxeqFMOYlxoc47uc2FWwk9SAZS8jFPBKshRK7WdCybrDCrxF6C3XvNrAC9de-HVa77utLqfg8cHkkOPXC2q8dEWal_NnBviKMLO0V-jF64eHn4_wzejaiDYo7dF7CnZ28SH-dJye831vCVsvvvloDJ4ag6Jiw_F6WjvRou1FifAoO9kK9azNC8NuX0Xbc2W85QEO0A-FkqUTy9o3suf3R4R1lS5hq2UFj0Jyyb9YMi53euOlaxCmZkWzS1-ArTCsiKMJXBLocAcTa_Yfv8zZvfj23OldDAAy-0vDB8SU6XVMEh7LcYKvuT-obK45rnRntcLg2UjCB9nhyCt6aqSFUre969WADcz1WuBL4uv3qDPEcXvaXNP9wAf0QP1A_7Q79nfSWGLZf2FJp9r8qSn-75Y4U-RKT_xdN1xIe3ZzRfJPtPerPK6yOBM-SVKYT3NyHCuEZpx9JFk42AjJ82-cao4PCyGIx5gSbVEJfzAqb4j6capEd_zVjByKgLF8UGr79pv1k-x8lNYObh7fpYs0yfwmjzfJcpkkFc7LLNugSFmdEMu0zDbzykGUKHgK507oKHIKjiFcWdK1L_MojKJwOU_ni3AeZUG4KIpinmZlEhWxWAgvCbHlZwSOR6BN7Zt8pFQM3DFJqKQle7rkLnSjGvOpr3wxUKNNHteIL_PEH1PnI_XfnOHd6w">