Ctrl+T deletes first line(s) of file

Some times when I run Auto Format (Ctrl+T) the first (2) line(s) of a file get deleted, e.g. the become blank.
image
Ctrl+Z restores these lines, but sometimes i had done so many updates before I started compile that I was left wondering why these errors occured.
image

The Auto Format does not always kick in when I initiate it, it never works

  • when the "Building sketch" is running (takes minutes after small changes

  • while "Indexing" is running

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...

Thanks so much for the additional information @Xinonix.

I am able to reproduce the issue and have submitted a report to the Arduino IDE developers:

If you have a GitHub account, you can subscribe to that issue to get notifications of any new developments.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.