Author Topic: Beautify + Function Parameter Alignment  (Read 1835 times)

edavison

  • New Community Member
  • Posts: 2
  • Hero Points: 0
Beautify + Function Parameter Alignment
« on: June 26, 2019, 09:59:18 PM »
I'm Slickedit 2012 v17.0.2.0 64-bit (the version available from corporate).

I set up a formatting profile for C/C++ so that I can beautify files quickly. In the profile, I have Function Parameter Alignment set to Continuation Indent. If I start typing a function and press enter, it indents how I want on the next line.

However, if from the profile window or from the tools menu I click "Beautify," it does Align on Parens instead. Is there a way to fix this?

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Beautify + Function Parameter Alignment
« Reply #1 on: June 27, 2019, 01:38:32 PM »
I don't know of any problems with that setting in that version.  Some simple samples I typed in didn't have any problems.

If you have an example you can post that shows the problem, post that, and attach a copy of your vusr_beautifier.xml file from your configuration directory.   You can look in the Help -> About SlickEdit dialog to find out where your configuration directory is.  And include the name of the profile you're using.  (It might have defaulted to 'My Default').

edavison

  • New Community Member
  • Posts: 2
  • Hero Points: 0
Re: Beautify + Function Parameter Alignment
« Reply #2 on: July 02, 2019, 01:24:16 AM »
So I was able to track down a bit more info from this... seems a bit interesting.

I noticed that functions near the top of the file I was working on were actually beautifying correctly - they were indenting as expected when I hit beautify. So I started removing sections of code between the ones that worked and the ones that didn't, and the culprit was some code that looked like this:

In another .h file which is included:
Code: [Select]
typedef struct
{
  id_enum  id;
  int      reset_value;
} struct_type;

In my file, the code that causes beautifier to change behaviors:
Code: [Select]
static struct_type struct_array[] =
{
  [ARRAY_ENUM_0] = {ID_0, 0},
  [ARRAY_ENUM_1] = {ID_1, 0},
  [ARRAY_ENUM_2] = {ID_2, 0},
};

If I remove this chunk of code, function params get aligned how I want. If I insert it back in, every function before that code aligns how I want, but everything after it does not, regardless of where I put it in the file. Is there maybe a setting I'm missing that causes it to pick up on some indentation I'm doing in the initialization and start using that from then on?

Attached the beautifier xml, profile is My Default.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Beautify + Function Parameter Alignment
« Reply #3 on: July 02, 2019, 02:11:59 PM »
Ah, the parser had a problem and didn't recover early enough (or well enough) to get the function decl right.

I remember that bug, v17 couldn't parse C99 designated initializers for arrays.  Unfortunately, the bug wasn't hot-fixable, so I don't think it was fixed until the next major release, v18.   I don't know of any workaround for v17.