Skip to content

Auto-format should differentiate array initializer braces from code block braces {} [imported] #939

Closed
@cmaglie

Description

@cmaglie

This is Issue 939 moved from a Google Code project.
Added by 2012-06-01T03:06:51.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Enhancement, Priority-Medium, OpSys-All, Component-IDE

Original description

What change would like to see?

Currently, auto-format turns:

int foo[] = { 1, 2, 3, 4, 5};

into:

int foo[] = {
1, 2, 3, 4, 5};

Because it treats all left / opening curly braces { as the start of a code block.

Instead, we should see if the brace is right after an equals sign and, if so, not insert a newline after it. Or, actually, we should probably just check if the matching closing brace is on the same line as the opening brace (in which case, the user probably wants it that way and we should leave it alone). That would apply to code to, for example:

for (int i = 0; i < 5; i++) { Serial.println(i); }

or:

void loop() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions