Author Topic: C++ Issue Formatting Struct Aggregate Assignments  (Read 1330 times)

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
C++ Issue Formatting Struct Aggregate Assignments
« on: April 21, 2015, 05:26:48 am »
Not sure if this has been reported and/or fixed ... but couldn't find it in the forums.

SE is struggling formatting C++ struct aggregates.  Have SE reformat the following assignments and they become very unsightly.

myStruct  myData1[] = { { 0x1000, 0x10},
                                      { 0x2000, 0x20},
                                      { 0x3000, 0x30} };

myStruct  myData2[] =
   { { 0x1000, 0x10},
      { 0x2000, 0x20},
      { 0x3000, 0x30} };


myStruct  myData3[] = {
                                      { 0x1000, 0x10},
                                      { 0x2000, 0x20},
                                      { 0x3000, 0x30}
                                   };


I finally put the first/last brace on their own line and that works ok.

SlickEdit Version 19.0.0.14  64-bit Windows 7 x64

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1307
  • Hero Points: 121
Re: C++ Issue Formatting Struct Aggregate Assignments
« Reply #1 on: April 21, 2015, 04:06:45 pm »
Yeah, there are not a lot of options for structure literals. Right now it's just doing a continuation indent, and being conservative with the placement of the outer braces.  Did you want #1 and #2 to move the outer braces so it will end up looking like #3?  Or did you just want the left braces to line up in those two cases, and the outer brace placement can stay the same?   

rgloden

  • Senior Community Member
  • Posts: 169
  • Hero Points: 5
Re: C++ Issue Formatting Struct Aggregate Assignments
« Reply #2 on: April 21, 2015, 07:04:59 pm »
I was expecting each test case provided that the format would not change (except maybe adding a space between 2 consecutive brackets), i.e. my examples are kind of already formatted as expected. 

I'm a C++ novice but it seems that if the user was just typing and letting SE format, the inner brackets should be lined up and be indented relative to the outer opening brackets.  I know this probably gets hard based on the number of variations.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1307
  • Hero Points: 121
Re: C++ Issue Formatting Struct Aggregate Assignments
« Reply #3 on: April 22, 2015, 07:33:06 pm »
I'll look at this for v20.  The beautifier is supposed to be conservative within structure literals to avoid messing up manual table layouts, so this is a bug.  But I may need to add or modify some settings to get a both a better version of what it does now, and a more hands off approach that would suit your examples.