4coder » Forums » Indentation behaviour
Zouch
Charly Mourglia
5 posts
#8488 Indentation behaviour
2 years, 6 months ago Edited by Charly Mourglia on Sept. 7, 2016, 8 p.m. Reason: Added namespace stuff, fixed typo

Hi,

Is there any way to customize indentation behaviour ?
I kinda don't like the way access specifiers (public, private, protected) and constructors initialization lists are (not) indented.

What I get :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Foo
{
    public:
    Foo();

    private:
    int bar;
    int baz;
};

Foo::Foo()
: bar(42)
, baz(1337)
{
}


What I would expect
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Foo
{
public:
    Foo();

private:
    int bar;
    int baz;
};

Foo::Foo()
    : bar(42)
    , baz(1337)
{
}


Also, being able to add keywords in some way to the indentation engine, to avoid messing thing up because of macros for example (yes signals, slots and Q_OBJECT, I'm looking at you...)

EDIT:
Fun fact, it looks like initialization lists are correct when inside namespaces (while public / private are still not)

Actual behaviour:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
namespace test
{
    class Foo
    {
        public:
        Foo();
        
        private:
        int bar;
        int baz;
    };
    
    Foo::Foo()
        : bar(42)
        , baz(1337)
    {
    }
}


What could be intended :
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
namespace test
{
    class Foo
    {
    public:
        Foo();
        
    private:
        int bar;
        int baz;
    };
    
    Foo::Foo()
        : bar(42)
        , baz(1337)
    {
    }
}


P.S.: Those indenting rules imply only me, and this might behave the way it's intended to, in this case that's why I would like to be able to customize them :P
Mr4thDimention
Allen Webster
462 posts / 2 projects

Heyo

#8494 Indentation behaviour
2 years, 6 months ago Edited by Allen Webster on Sept. 7, 2016, 9:09 p.m. Reason: wording

Today is your lucky day, good sir, because right this very day, in just thirty minutes, I am going to go live on Twitch and reimplement the auto indent rule entirely on the customization side. Moving it to the customization side will let me offer more built in flexibility, and it will mean that users who maintain their own customizations can tweak the indenting rule to their hearts content.

In the mean time: yes. This is the expected behavior for alpha 4.0.10.
Zouch
Charly Mourglia
5 posts
#8497 Indentation behaviour
2 years, 6 months ago

w00t, I luv dat !