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

    <tr>
        <th>Summary</th>
        <td>
            clang-format does not always remove spaces on the first run when merging empty lines
        </td>
    </tr>

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

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

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

<pre>
    I am running VS Code 1.64.2 on linux, and clang as a part of C/C++ ms-vscode extension (very standard, version 1.10.5, it uses clang 14.0.0 afaik). Using this ```.clang-format```:

```
BasedOnStyle: Google
Language: Cpp
IndentWidth: 4
```

and this (reduced as much as possible) cpp file:

![image](https://user-images.githubusercontent.com/1613138/183921609-14decd77-7cdc-43f2-a832-d827a3d0b31a.png)

(note 4 spaces on line 4)

Upon formatting on save (the whole file, not just modified lines), this happens:

![image](https://user-images.githubusercontent.com/1613138/183922055-e16c585f-5259-4fdd-8c10-b0ae1aaf783d.png)

Line 4 is indented twice (8 spaces). Saving and formatting the file again fixes the indentation (4 spaces). This problem is hard to pinpoint, it disappears upon small changes, for example, empty line before `private:` is essential, so is the `private:` line itself. On the other hand, I discovered it in a complex piece of code, with several extra lines after the problematic snippet and the following `private:` section.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VE2PnDgQ_TX0pQTC5qPpA4edjiYaKVIOs9k9V2MDTsBG2HTP_PutMp1kJsl1JbqBquL51auPi1Ov7RPgDOtmrbED_PMMZ6c0iKwuMwnOwmTs9pLIM6BV0E1IQegBYcE1gOvhnMhH-j3QBbNPr77j7_VL0NYb-j6RzVWvr-ADAeCqGIoM0ScykWcVW0yAzWt_P0CUWZ7lgD2ab4k8ZfDFM7kwGg9Jne9XFmPT3q0zhh_WpPgryT8k-ff_H_b4-oBeq8_2ObxOmiLho3MDPUXfJ0LbcIj287LsxiertA3_GhVGtpd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