Community
Participate
Working Groups
Build Identifier: 20100520-1308 / CDT 7.0.0.201005241228 With array initializers, the formatting rules are not applied reliably to sub-structure initializers. For example: typedef struct { int a; int b; } CHILD_T; typedef struct { int a; CHILD_T b; } PARENT_T; PARENT_T sample = { .a = 1, .b = { .a = 1, .b = 2, } }; If you start out with the above format, you can get it to stay that way. But if the .b initializer is already on one line, it will stay that way even if the format rules dictate a new line should be inserted. For example: PARENT_T sample = { .a = 1, .b = { .a = 1,.b = 2 }}; turns into PARENT_T sample = { .a = 1, .b = {.a = 1,.b = 2} }; Also, in a related note the formatter does not insert spaces after the curly braces, even though I have configured it to do so. And in a third, but related note: PARENT_T sample = { .a = 1, .b = {.a = 1,.b = 2}, .b = {.a = 1,.b = 2} }; There is no way to have the formatter automatically remove that extra blank line between the initializers. I can set number_of_empty_lines_to_preserve to zero, but that will remove all blank lines, not just the ones inserted randomly into initializers. Reproducible: Always Steps to Reproduce: 1. Source -> Format
Fixed in HEAD and cdt_7_0.
*** cdt cvs genie on behalf of aleherbau *** Bug 314958 - Editor does not format array initializers correctly [*] CodeFormatterVisitor.java 1.79 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java?root=Tools_Project&r1=1.78&r2=1.79 [*] CodeFormatterTest.java 1.55 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java?root=Tools_Project&r1=1.54&r2=1.55 [*] CodeFormatterUtil.java 1.16 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java?root=Tools_Project&r1=1.15&r2=1.16