Skip to content

No indent for namespace with auto format #6812

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

Closed
staadecker opened this issue Oct 10, 2017 · 4 comments
Closed

No indent for namespace with auto format #6812

staadecker opened this issue Oct 10, 2017 · 4 comments
Labels
Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature

Comments

@staadecker
Copy link

namespace {
   //Some code
}

after running auto format (Ctrl+T) becomes

namespace{
//Some code
}

To me, this seems like incorrect formatting.

@per1234
Copy link
Collaborator

per1234 commented Oct 10, 2017

Just a note that it is possible to customize the auto format configuration:

  1. Open {Arduino IDE installation folder}/lib/formatter.conf in a text editor.
  2. Add the line:
indent-namespaces
  1. Save the file to the folder of the link shown after File > Preferences > More preferences can be edited directly in the file. The reason for this is so the customization will persist after updating to a new version of the IDE.
  2. Restart the Arduino IDE.

You can find documentation of all the configuration options here:
http://astyle.sourceforge.net/astyle.html

That's not to say that it isn't reasonable to request that this be set by default, but only to make it clear that we do each have the option to configure the formatter to our own preferences if the defaults are not to our liking.

@staadecker
Copy link
Author

@per1234 Thank you, that worked. If you want this to be the default, and point me in the right direction I can start working on a pull request...

@per1234
Copy link
Collaborator

per1234 commented Oct 10, 2017

At a glance it does seem sensible to indent.

I tend to just accept whatever style conventions were originally set for the formatter but I don't know whether that option was intentionally left out or just never considered. It's somewhat unfortunate to change the established standards but I don't think this change would have a huge impact since it's not very common to see namespaces used in Arduino sketches. It's certainly better to make the change now rather than later if it's going to be done.

If you want to submit a pull request the file is here: https://github.com/arduino/Arduino/blob/master/build/shared/lib/formatter.conf

@cmaglie
Copy link
Member

cmaglie commented Oct 30, 2017

As said in #6813 we will never find a configuration that match everyone's personal taste, so I'll close this as wontfix and just keep the existing configuration.

@cmaglie cmaglie closed this as completed Oct 30, 2017
@cmaglie cmaglie added the Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature label Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Wontfix Arduino has decided that it will not resolve the reported issue or implement the requested feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants