4coder » Forums » auto indentation bug?
CirdanValen
Ryan
5 posts
#13585 auto indentation bug?
2 weeks, 6 days ago

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
}
Jim0_o
Jim R. Didriksen
53 posts
#13588 auto indentation bug?
2 weeks, 5 days ago Edited by Jim R. Didriksen on Nov. 24, 2017, 1:24 a.m.

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.))

- Jim RMHD
Mr4thDimention
Allen Webster
289 posts
2 projects

Heyo

#13590 auto indentation bug?
2 weeks, 5 days ago

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?
Jim0_o
Jim R. Didriksen
53 posts
#13591 auto indentation bug?
2 weeks, 5 days ago Edited by Jim R. Didriksen on Nov. 24, 2017, 2:42 a.m.

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

- Jim RMHD
CirdanValen
Ryan
5 posts
#13592 auto indentation bug?
2 weeks, 5 days ago Edited by Ryan on Nov. 24, 2017, 5:41 a.m.

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.

Kknewkles
10 posts
#13609 auto indentation bug?
2 weeks, 3 days ago

This is what I'm having now:

This linguistic cadaver of a nickname is pronounced [K'nu:kls].
In case anyone's interested.

27.7.15
I had this in a signature? Wow! :D
CirdanValen
Ryan
5 posts
#13663 auto indentation bug?
1 week, 4 days ago

Looks like it was fixed in 4.0.25. Thankyou!!