Description
Describe the problem
The formatting style produced by the Arduino IDE "Auto Format" feature can be customized by the user. This customization can be done either on a per-sketch basis or else globally (#1019). The global configuration file can be placed in either of two locations:
- Configuration folder (e.g.,
C:\Users\per\.arduinoIDE\.clang-format
) - Data folder (e.g.,
C:\Users\per\AppData\Local\Arduino15\.clang-format
)
🐛 If Arduino IDE is started from a path on a different drive than the one containing the global formatter configuration file, the file does not take effect.
To reproduce
Equipment
Extra drive (type and capacity don't matter).
Steps
- Select File > Quit from the Arduino IDE menus if it is running.
- Create a file at the following path:
with the following content:
C:\Users\per\.arduinoIDE\.clang-format
IndentWidth: 8
- Open a command line terminal on a drive other than
C:\
. - Start Arduino IDE from the command line terminal.
ⓘ The command line was only used as a convenient way to start the IDE from a different drive. The bug also occurs if the IDE is installed to a different drive and started normally. - Wait for the IDE to finish starting up.
- Select File > New from the Arduino IDE menus.
- Select Edit > Auto Format from the Arduino IDE menus.
🐛 The indentation is not changed to 8 spaces according to the global formatter configuration.
Expected behavior
Global formatter configuration files are recognized regardless of which drive the IDE was started from.
Arduino IDE version
2.0.1-snapshot-bc264d1
Operating system
Windows
Operating system version
10
Additional context
The cause of the bug is the redundant URI to filesystem path conversion applied to the global configuration file paths:
This causes the paths to have this form:
\Users\per\.arduinoIDE\.clang-format
\Users\per\AppData\Local\Arduino15\.clang-format
That points to the correct place when the IDE is started from C:\
, but not when it is started from another drive.
The local configuration file path is only subject to a single URI to filesystem path conversion, so it is formatted correctly, meaning the bug does not affect this configuration method:
C:\Users\per\Documents\Arduino\sketch_oct9a\.clang-format
Originally reported by @Willem43T at https://forum.arduino.cc/t/clang-setup-where-is-clang-format/1016866/17
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details