CLion C++ Variable Alignment -> Incorrect?

已回答

In the latest CLion version, the alignment of variables are inconsistent:

- unassigned pointer and non-pointer types need reformatting twice to align e.g.:

    int x;

    double y;

    do not align at the variable name, unless one reformats twice; and

- even with the former, if the spaces are set to be "After *", and "After &" (as opposed to "Before */&") in Editor -> Code Style -> C/C++, they do not align at all with pointer types. E.g.:

    int y;

    double *z;

    - do not align.

- declared but unitialized values do not align with a declaration/initialization expression when attempting to initialize already declared; e.g:

     int x;

     x = 5;

     double y = 20;

    - (the last two expressions do not align)

 

    [[[or..........]]]   

 

    auto sz = items.size();

    this->_sz       = this->_used = sz;

    this->_elems = new T[sz];

    - (the first expression does not align with the latter two).

 

Any ideas?

 

Cheers

2

Hello!

The first and the second cases:

CLion aligns variables if there is no blank lines between them.

The third case:

x = 5; belongs to the "Assignment statement" group and double y = 20; belongs to the "Variable groups" group therefore they are not aligned relative to each other.

1

请先登录再写评论。