Author Topic: C/C++ Allman style: setting to place opening brace to desired indentation level?  (Read 234 times)

pieterc

  • Community Member
  • Posts: 36
  • Hero Points: 3
Hi there!

I have set my C/C++ formatting to the Allman style. I can't seem to find the setting to control where the opening brace should go. For example when I start at the end of an existing if statement (cursor position indicated with pipe character):
Code: [Select]
if(f == 0)|

Then I press enter and the cursor moves to the next line and is correctly indented (for a single statement):
Code: [Select]
if(f == 0)
    |

Then when I type the opening brace, it is autocompleted as follows:
Code: [Select]
if(f == 0)
    {|
}

I would prefer the opening brace to be unindented and my cursor to be here:
Code: [Select]
if(f == 0)
{
    |
}

Is that possible?

Thanks in advance,
Pieter

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1661
  • Hero Points: 141
Usually the changing the Languages -> Application Languages -> C/C++ -> Auto Close setting for Brace to "After blank line" would do what you want.  But I can't reproduce the brace not being re-indented under the "if".  I've inferred some of your settings from your description, but I must have something different.  Maybe there's a but with the combination of settings you have.  Can you post your user.cfg.xml from from your configuration directory?  I can take that and try to reproduce and see what's going on there.

 

pieterc

  • Community Member
  • Posts: 36
  • Hero Points: 3
Hi Patrick,

Thanks for looking into this  :) Attached is my "user.cfg.xml" file. I changed the "Languages > C/C++ > Auto-Close > Brace {} > Put closing brace" setting to "After blank line" but the behavior is still the same.

Thanks in advance,
Pieter

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1661
  • Hero Points: 141
So this ended up being a bug that only happens to trigger in your case because there's no space between the 'if' and '('.  I flubbed that typing in your example, so that's why I didn't reproduce it.

I'm checking in a fix.  It should go into the 26.0.2 we're putting out this or next week, but if doesn't make it for that build, I'll send you a file you can load to fix it until the next hotfix comes out.


pieterc

  • Community Member
  • Posts: 36
  • Hero Points: 3
Excellent, thanks  ;D