Do you have "Auto Save" disabled in your preferences?
There is a similar known bug with the autoformat which only happens for me with the auto save off:
The problem is that the formatting is handled by the Arduino Language Server. In order to provide its other capabilities (code suggestions, problem detection, editor hover, go to ..., peek), the language server must be aware of the complete sketch program, which means processing all the libraries it uses after every change. While it is busy doing that processing it is not able to multitask to format the sketch, so the formatting is delayed until the processing operations complete.
Auto save is on, and the error can be provoked:
I have a second tab with a .h file,
Ctrl+T on that tab always empties the first line and inserts onother blank line. Very consistent behaviour.
I added 2 comment lines at the top of the file so I do no longer lose the #includes...