Author Topic: 19.0.0.14 Win64: Brace expansion has wrong indent  (Read 1999 times)

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
19.0.0.14 Win64: Brace expansion has wrong indent
« on: November 17, 2014, 02:36:13 pm »
The brace expansion performed when I type an opening brace after an "if" is not indenting correctly. See the code below for an example. Note that the braces in red are not correct. It should be indented one level.

switch( test )
    {
    case test_case:
        {
        if( something )
        {
            }
        }
        break;
    }

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #1 on: November 17, 2014, 03:08:29 pm »
I haven't been able to reproduce this so far.  Do you have adaptive formatting or "Beautify while typing" on? If so, does turning them off change the behavior?

If you could post your CONFIG_DIR/vusr_beautifier.xml and your CONFIG_DIR/vusrdata.e (or vunxdata.e for linux), that might be enough for me to be able to reproduce it.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #2 on: November 18, 2014, 01:08:12 pm »
Yes, I do have adaptive formatting and beautifier settings.
Files attached, thanks.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #3 on: November 30, 2014, 07:44:39 pm »
Any progress on this issue?

It is also exhibited if after the last brace in an if block, I press enter and type "else", the else is not aligned with the if, but with the brace. Like this:

if( x )
    {
    }
    else
        {
        }

In addition to this, our organization puts statements in the first column inside of a function rather than indenting. If I type "if( x )" followed by a return and then type an open brace, the brace is not indented even though I have this style defined. Here's an example:

void test( void )
{
if( x )
{
}

}

The braces in red should be indented. This problem has existed for a while and I have reported it before. But the other issues are new with v19.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #4 on: December 01, 2014, 10:11:46 pm »
For the original issue, I can't reproduce this.  What I'm doing is starting with an empty file, adding one function, and then typing the code you have in your post. 

I suspect that adaptive formatting may be coming into play.

So, some questions:
  • Can you reproduce it just adding your code to a function in an empty file?
  • If you go to a file where you can reproduce the problem, if you run set-var def_beautifier_aff_bracestyle 0 in the command line, can you still reproduce the problem?

I can't get the else alignment problem in your last message to happen either.  When I press return after the } of the if statement, my cursor ends up in the same column as the "if".  I'll need to take a closer look at that, it doesn't strike me as something that adaptive formatting could tweak.

The indent problem in column 1 is an old limitation.  If I remember right, it's easy to change, but requires a lot of unit test updates/additions to make sure it doesn't make any wheels fall off the wagon.  I'll look again once we figure out the previous problems.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #5 on: December 04, 2014, 01:57:00 pm »
Thanks for the response.

Here is what I just did (using VIM emulation) ...

I typed in the following:
void test( void )
{
switch( x )
    {
    case y:
    }
}

After typing the case y:
- I typed an 'o' to open a line
- I typed "if " and this indented my if and created a matching set of parens with my cursor in the center of the parens, so it now looks like this:
void test( void )
{
switch( x )
    {
    case y:
        if(  )
    }
}

- Then I typed 'z' ESC 'o' '{' and it now looks like this:
void test( void )
{
switch( x )
    {
    case y:
        if( z )
        {
            }
    }
}

Then to test your suggestion on using "set-var def_beautifier_aff_bracestyle 0", I deleted the if block so it now looks like this:
void test( void )
{
switch( x )
    {
    case y:
    }
}

- I then executed "set-var def_beautifier_aff_bracestyle 0" on the command line and performed the same steps as above with the "if" block and I got the same result.

Note that I am using my custom formatting settings as shown in the attached image. I'm wondering if this formatting was included in the files that I uploaded before?

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #6 on: December 04, 2014, 02:27:00 pm »
Yep, those formatting settings are what's in vusr_beautifier.xml.   I just double checked, and the formatting setup I have does have the profile "garmin" in it, so I think I've got the correct one.

This post gives me an idea though, thanks for the informaion.  I'll see if I can figure out something this morning.

I can reproduce it with those instructions.
« Last Edit: December 04, 2014, 02:34:02 pm by patrick »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #7 on: December 04, 2014, 07:58:19 pm »
I've put in a fix for the first problem which will be in the next hotfix.  The problem was brace style-3 specific.

For the second problem with the else being in the wrong column, am I right in now assuming that you're hitting 'o' in command mode when you're on the line with the closing brace, and the cursor ends up on the line below in the same column as the '}'?   When I was failing to reproduce it, I was using enter, or ctrl-enter, but I can see a problem if you're using the o command to move insert a newline after the '}'.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #8 on: December 05, 2014, 01:40:25 pm »
Thanks for the fix Patrick!

Yes, you are exactly right in describing what I'm doing - 'o' after the closing brace.
And I now see I said I was pressing Enter before - sorry about that. I see that Enter does work, but not 'o'.
« Last Edit: December 05, 2014, 01:42:54 pm by davew »

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #9 on: December 05, 2014, 04:02:41 pm »
Ok, good.  Getting the fix in for that is the next on my list.  And then looking into the column 1 indent problem after that.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #10 on: December 08, 2014, 02:01:09 pm »
Sounds great Patrick. I'm especially looking forward to the column 1 fix. That one has been bugging me for some time.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 720
  • Hero Points: 31
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #11 on: December 16, 2014, 02:09:56 pm »
I've changed o/O in the vim emulation so it puts the cursor in same column as nosplit-insert-line, so it follows syntax indent rules for languages that have that level of support.  It will be in the first hotfix after the 19.0.1 update.

I'll get to the column 1 issues after 19.0.1 goes out the door.

davew

  • Senior Community Member
  • Posts: 195
  • Hero Points: 5
Re: 19.0.0.14 Win64: Brace expansion has wrong indent
« Reply #12 on: December 17, 2014, 01:14:08 pm »
Awesome, thanks for the great work Patrick.