Skip to content

[Bug] Auto formatting does not work if there is an 'R "===== (' in the sketch? #10946

Open
@rtek1000

Description

@rtek1000

Hi,

Auto formatting (Ctrl+T) does not work if there are:

const char webSite1[] PROGMEM = R"=====(
"abc"
)=====";

But Auto formatting works if there is no line break:

const char webSite1[] PROGMEM = R"=====("abc")=====";

In both cases the compilation is successful.

Arduino IDE 1.8.13 (Linux)

Activity

per1234

per1234 commented on Nov 11, 2020

@per1234
Collaborator

There is a bug report about it here in the repository of the Artistic Style tool used by the Arduino IDE's Auto Format feature: https://sourceforge.net/p/astyle/bugs/519/
It is claimed to be fixed (though there hasn't been a release of Artistic Style since that time).

rtek1000

rtek1000 commented on Nov 11, 2020

@rtek1000
Author

Interestingly, it may be better for the user to leave this type of variable in an additional file, such as index.h,

#include "index.h"

And thus can also use an online formatter to improve the reading of the code:

https://www.freeformatter.com/html-formatter.html

<html>
<body>
</body>
</html>
<html>
   <body></body>
</html>
rtek1000

rtek1000 commented on Nov 11, 2020

@rtek1000
Author

There is a bug report about it here in the repository of the Artistic Style tool used by the Arduino IDE's Auto Format feature: https://sourceforge.net/p/astyle/bugs/519/
It is claimed to be fixed (though there hasn't been a release of Artistic Style since that time).

I asked in the post when a new version of this software will be released, thanks!

added
Upstream notifiedRelated to a software component maintained by someone else. They have been notified of it
on Mar 29, 2021
roblatour

roblatour commented on May 23, 2021

@roblatour

I add that in other parts of the code, when this bug appears it puts extra spaces before / after the slash character "/" if they are surrounded by quotes. For example "one/two" gets transformed to "one / two" even if is in a statement 50 lines away.

per1234

per1234 commented on May 25, 2021

@per1234
Collaborator

Hi @rtek1000. There is some good news related to this bug. #11543 will change the Arduino IDE from using the Artistic Style formatter to ClangFormat, which is able to handle raw string literals correctly.

ClangFormat is very popular and actively developed, and even suggested by the Artistic Style developer in this statement where they state that they are no longer able to play as active a role in developing Artistic Style.

You can give the test build for the ClangFormat/Arduino IDE integration a try. The downloads are available here:
#11543 (comment)
If you do try it out, please let us know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: IDEThe Arduino IDEType: BugUpstream notifiedRelated to a software component maintained by someone else. They have been notified of it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [Bug] Auto formatting does not work if there is an 'R "===== (' in the sketch? · Issue #10946 · arduino/Arduino