auto indentation bug?

I think I found a bug in the auto indentation code. Haven't had a chance to look at the indentation code itself, but here is how to reproduce it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
void myfunc()
{
    if(true)
    {
        int testVar; // Before the if block, it works fine
  
        if(anotherIf)
        {
        }

    int myVar; // Anything after the second if block doesn't get indented properly
    }

int testVar2; // It also doesn't work correctly down here
}
Interesting, I had a hunch so I copy/pasted this code into a file to test it out and the code layout got fixed.

Tho if I went to a } and hit enter after it the cursor did move to where you are showing us in your example.

Edit: Tho if I paste the example code in twice the second copy will be missing one indent/set-of-spaces. (as if it has counted one less scope_open)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void myfunc()
{
    if(true)
    {
        int testVar; // Before the if block, it works fine
        
        if(anotherIf)
        {
        }
        
        int myVar; // Anything after the second if block doesn't get indented properly
    }
    
    int testVar2; // It also doesn't work correctly down here
}

void myfunc()
{
if(true)
{
    int testVar; // Before the if block, it works fine
    
    if(anotherIf)
    {
    }
    
    int myVar; // Anything after the second if block doesn't get indented properly
}

int testVar2; // It also doesn't work correctly down here
}


Now if you copy and paste all of this code into a 4coder file it will initially be formatted correctly...



((The WRONG idea I wanted to test: Was to add a (few) line(s) in the deepest scope, checking if the scope count didn't get incremented before a scope was filled with something.))

Edited by Jim R. Didriksen on
This is a little wild. I would have thought something like this would have been caught before now, so I'm wondering if I changed this recently. Could you clarify a few details for me:

4coder Version?
Is this virtual-whitespace or text indentation?
What I tested, (just copying the code in a few times and doing minimal edits to see where the cursor moves ex. after a scope) was in version 4.0.24.

I checked in some other versions and found that this bug is also present in version 4.0.23 but not 4.0.22 or 4.0.21.

Very interesting: Toggling(on and off/off and on) virtual-white-space actually removed the bug for me. Edit:(it seemed) (~~I'm not sure if virtual-white-space was on or off initially to be honest.~~ The bug doesn't show up with virtual-white-space on.)

Edit: Corrections

Edited by Jim R. Didriksen on
This is in the latest 4.0.24

Happens when using auto_tab_range and auto_tab_line_at_cursor.

I don't have anything in the customization that sets virtual white space, so I don't know what it is set to...I'm guessing the default is off?


EDIT: I tried it with virtual white space turned on (buffer_set_setting(app, &buffer, BufferSetting_VirtualWhitespace, 1);), and I still have the same issue.


Edited by Ryan on
This is what I'm having now:
Looks like it was fixed in 4.0.25. Thankyou!!