Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global custom formatter configuration not used if on different drive than IDE started from #1551

Open
3 tasks done
per1234 opened this issue Oct 9, 2022 · 0 comments
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

Comments

@per1234
Copy link
Contributor

per1234 commented Oct 9, 2022

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

  1. Select File > Quit from the Arduino IDE menus if it is running.
  2. Create a file at the following path:
    C:\Users\per\.arduinoIDE\.clang-format
    
    with the following content:
    IndentWidth: 8
  3. Open a command line terminal on a drive other than C:\.
  4. 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.
  5. Wait for the IDE to finish starting up.
  6. Select File > New from the Arduino IDE menus.
  7. 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:

return FileUri.fsPath(dataDirUri);

return FileUri.fsPath(configDirUri);

const folderPath = FileUri.fsPath(await folderUri);

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
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project os: windows Specific to Windows operating system labels Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant