Type: LanguageService
Describe the bug
To Reproduce
Expected behavior
Replace old text with new text instead of appending directly to the end of the file.
Screenshots

Additional context
The code I am going to format is that I copied it directly from the other place to the editing area.
I believe this is a duplicate of https://github.com/microsoft/vscode-cpptools/issues/4091 (although your repro steps are slightly different). The document is becoming corrupted when it's saved and the formatting is revealing the corrupted document.
Closing as duplicate.