Global custom formatter configuration not used if on different drive than IDE started from #1551
Open
3 tasks done
Labels
os: windows
Specific to Windows operating system
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
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:
C:\Users\per\.arduinoIDE\.clang-format
)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
C:\
.ⓘ 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.
🐛 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:
arduino-ide/arduino-ide-extension/src/node/clang-formatter.ts
Line 84 in bc264d1
arduino-ide/arduino-ide-extension/src/node/clang-formatter.ts
Line 89 in bc264d1
arduino-ide/arduino-ide-extension/src/node/clang-formatter.ts
Line 95 in bc264d1
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
The text was updated successfully, but these errors were encountered: