Author Topic: Formatting  (Read 2374 times)

SeeCwriter

  • Senior Community Member
  • Posts: 146
  • Hero Points: 1
Formatting
« on: April 12, 2019, 05:33:17 PM »
I'm using v23.0.1.2 of SE and the C/C++ language.  When you type an 'if' statement the editor automatically adds the opening and closing braces as it's supposed to. But when I add an 'else' part things sometimes go terribly wrong.
If I try to insert an if..else statement in the middle of existing code, the if portion is fine. When I type 'else' followed by an open brace, the editor will do one of 2-things. 1) it will only enter the opening brace, not the closing brace also as with the 'if', and it uses the next closing brace it finds as the closing brace to the else, which can be the closing brace of the function that it's in. And if I backspace to remove the open brace, because I want it on the next line, it will delete it and the closing brace it found. And I don't always notice that it happened until I get all kinds of compiler errors. or 2) it indents everything to the end of the file assuming it's all going into the else section. This has caused all kinds of confusion and time.
It seems prone to happen when there are no blank lines between the lines of code I'm inserting into. If I enter a number of blank lines where I want to add code, then go back to add the code, that seems to work. 

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Formatting
« Reply #1 on: April 15, 2019, 12:24:11 AM »
Could you post your user.cfg.xml file, from you config directory?

SeeCwriter

  • Senior Community Member
  • Posts: 146
  • Hero Points: 1
Re: Formatting
« Reply #2 on: April 15, 2019, 02:35:35 PM »
Attached.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Formatting
« Reply #3 on: April 16, 2019, 02:13:06 PM »
So far I haven't been able to reproduce those.  I've tried variations on what line the 'else' starts on and what line I type the '{' on.  I had hoped having your configuration would have been enough.  Do you have an example it happens with?

SeeCwriter

  • Senior Community Member
  • Posts: 146
  • Hero Points: 1
Re: Formatting
« Reply #4 on: May 08, 2019, 08:43:41 PM »
I found the secret to recreate the issue.  On some project files written by someone else, they put the open & close brace at the same indentation level as the code they wrap. Example:
Code: [Select]
void MyFunc()
   {
   if ( this )
      {
      do_that();
      }
   else
      {
      do_the_other_thing();
      }
   }  // MyFunc()

When that is the case, and I insert an if..else between existing lines of code, and type else{ (no space between the 'e' and '{' and hit return, the open brace will be put on the next line and the closing brace is the next closing brace found, which may be the function's closing brace.


patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Formatting
« Reply #5 on: May 09, 2019, 07:46:59 PM »
I'll take a look at this in the afternoon.  Thanks for the update.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Formatting
« Reply #6 on: May 16, 2019, 05:49:57 PM »
This ends up being a little tricky when the indents are inconsistent, as we look at the indent as a factor when trying to forward match an existing brace.  But I can fix it so we don't pair up with obviously bad choices, like the closing brace of the function.  The fixes will be in the next hotfix.

SeeCwriter

  • Senior Community Member
  • Posts: 146
  • Hero Points: 1
Re: Formatting
« Reply #7 on: May 16, 2019, 06:38:30 PM »
Thank you for the update.