Beta 5: Auto Format not Working

In Beta 5 I can not seem to get Auto Format to actually format the code.

Pressing CRTL+T does nothing, neither does selecting it in the menu.
I even tried highlighting the code and trying it what way as well but still nothing.

The code complies and runs fine though in BETA 5

Hi @SniffTheGlove. Thanks for your report.

Do you have a board selected from either the Tools > Board menu or the new dropdown board and port menu?

Because the new auto format is based on the Arduino Language Server and the language server is architecture-dependent, auto format only works when you have a board selected.

Yes, in the drop down I have "Ardunio Uno at COM4" selected.

I can also upload the code to the Uno and run it fine.

Additional, I just copied the code from Beta 5 and pasted it into IDE V1.8.13 and tried Auto Format and it formatted ok.

So back to Beta 5 and pasted over the original code and tried again but still nothing in Beta 5. HTH

I can confirm the auto format is flakey.
It will sometimes format OK (had me think it actually started working), next time mess up and then, just ignore the selection.

Willem

It seems to be at least on my PC due to the PC either sleeping or some other variable.

If I load a script up into a new IDE session I can auto format at least once or twice but if I have the script open in the IDE when my PC goes to sleep it will not auto format once the PC has woken up.

I wonder if it was due to the com connection not connecting from the IDE, so I then compiled and uploaded the script to my UNO, upon completion I tried to auto format again but still nothing, so it's not due to a com connection between the IDE and the UNO.

Where is the auto format library stored?

Auto format is facilitated by the Arduino Language server, which is located in the resources/app/node_modules/arduino-ide-extension/build subfolder of the Arduino IDE installation.

The actual formatting tool is clangd, at resources/app/node_modules/arduino-ide-extension/build/bin subfolder of the Arduino IDE installation.

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

The bug of Auto Format frequently failing to have any effect is being tracked by the Arduino IDE developers here:
https://github.com/arduino/arduino-ide/issues/396

There are also multiple known bugs where when it does have an effect, it misbehaves:

https://github.com/arduino/arduino-ide/issues/543