Qt Creator: Undesired extra indentation level in function argument continuation



  • (this problem was already mentioned in this topic, but the forum suggested me to create a new topic due to the existing one being old)

    My indent style is set to 4 spaces. However, Qt Creator (4.1.0, on Red Hat Enterprise Linux 7.2 64bit) always inserts 8 spaces in this scenario:

    SomeReturnType someFunction(
    ••••••••SomeType param1,
    ••••••••SomeOtherType param2);

    I just want four spaces:

    SomeReturnType someFunction(
    ••••SomeType param1,
    ••••SomeOtherType param2);

    I believe this is a bug. I have carefully looked at all code style options, this does not seem to be customizable. If it is not customizable, then the default should be to use the regular indent, i.e. 4 spaces in my case.

    I want to emphasize by how annoying this is by giving an example. The code base I work with is mostly indented as above (four spaces for parameters). I believe this is a very common style, if not the most common. Whenever I want to add an extra argument by duplicating an existing line, Qt Creator "fixes" (incorrectly) the indentation, and I have to manually go to the beginning of the line and delete four spaces.

    Original code:

    SomeReturnType someFunction(
    ••••SomeType param1,
    ••••SomeOtherType param2);

    Duplicating line 2 with Ctrl+Alt+Down:

    SomeReturnType someFunction(
    ••••SomeType param1,
    ••••••••SomeType param1,
    ••••SomeOtherType param2);

    Need to manually delete the spaces in order to get:

    SomeReturnType someFunction(
    ••••SomeType param1,
    ••••SomeType newParam,
    ••••SomeOtherType param2);

    Typically, I have to perform this manual fix dozens of times per days. It becomes very irritating after a while. Sometimes, I am tempted of entirely disable auto-indentation just because of this issue (though the benefits of auto-indentation in most cases outweigh the annoyance in this specific scenario, so I do keep it on).

    Anything I missed, or should this be submitted as a bug/suggestion?

    Thank you,
    Boris

    Note 1: this undesired behavior also happens for function/macro calls, not only for function declarations.

    Note 2: The option "Align continuation lines" is irrelevant, since it only concerns cases when the first parameter is at the same line as the function name. More precisely, it lets me choose between the style:

    SomeReturnType someFunction(SomeType param1,
    SomeOtherType param2);

    and the style:

    SomeReturnType someFunction(SomeType param1,
    •••••••••••••••••••••••••••••••••••••••••••SomeOtherType param2);

    But in all cases gives me the following indentation (even by using the option "With regular indent"):

    SomeReturnType someFunction(
    ••••••••SomeType param1,
    ••••••••SomeOtherType param2);

    Note 3: By the way, "Align continuation lines" should probably also have the option to have the following style:

    SomeReturnType someFunction(SomeType param1,
    ••••SomeOtherType param2);


  • Qt Champions 2016

    Hi
    Its the same on windows 10.
    No matter what i alter tab to, it always indent 8 for function headers.
    It does affect code in other places ( it respects indention) but it seems to do differently
    in your cases.

    I dont know if it will be considered a bug but it clearly do not work smoothly in the shown cases.
    You could open report and see what the devs says.

    alt text


  • Qt Champions 2016

    @mrjj said in Qt Creator: Undesired extra indentation level in function argument continuation:

    Hi
    Its the same on windows 10.
    No matter what i alter tab to, it always indent 8 for function headers.
    It does affect code in other places ( it respects indention) but it seems to do differently
    in your cases.

    Probably because Text Editor > Behavior is only half the story. There's also the C++ options in C++ > Code Style > Edit ...:



  • Alright, I have reported with much more details in this existing issue: https://bugreports.qt.io/browse/QTCREATORBUG-6864

    Note that I believe Text Editor > Behavior is only for non-C++ text (though mine is also set top spaces/4/4)
    I was indeed playing with C++ > Code Style > Edit.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.