Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator (latest as of 116-26) issue with indentation

QtCreator (latest as of 116-26) issue with indentation

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
1 Posts 1 Posters 25 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • osirisgothraO Offline
    osirisgothraO Offline
    osirisgothra
    wrote last edited by
    #1

    If you have a function with:

    void someFunction(bool condition)
    {
        if(condition)
            for (stuff)
                for (more stuff)
                     some.single.line.operation();
    }
    

    ...in the next function, ONLY when refactoring has hadded the function itself, the auto-indent will be somewhat incorrect....

    someOtherFunction(bool something)
    {
                            if (something)
                            ^ ---- indentation starts here with auto-indent
    }
    

    So far, this ONLY happens when refactoring has added "SomeOtherFunction", If I REMOVE the function, or make changes to the previous function (anything that forces a re-read of the file or the reset of the indenter's count), things work as expected from that point on.

    So again, this is only when adding a refactored function after such a function. This is about all I was able to narrow down and it seems to only do this sometimes. If I figure out any way to refine this to where it happens 100% of the time, I'll annotate that on.

    The current workaround that I use is to just cut and then paste the refactored function back into the code to ensure the autoindenter has whatever counts it keeps accurate as possible.

    As for the specific refactoring that I used here, it was the refactor that adds a function body from the CLASSNAME.h file:

    ... in classname.h ...

    void SomeOtherFunction(bool something);
                      ^--- R-click and select refactor->generate function in .cpp file
    

    Which causes the function to be put into classname.cpp, where the result is as it is shown in the snippet above this one.

    Waiting for the parser to update everything (syntax highlighting updated and applied, everything gets linted) and do not any parsers turned off in this case does not seem to change the outcome.

    My suggestion is maybe fire whatever event is triggered when text is changed by the user.

    As an example, disabling signals while updating a text box and re-enable them afterwards to prevent the text box from firing signals as if the user had changed the text is often used.

    This may or may not be the case here, but surely it is something similar to that. In which case there is a possible solution, were the developers ever at a point where they can address this:

    It may be that there is a need to fire some event or call some function that is a result of that event being fired, in order to update the autoindent's counter or positioning at that point in the document.

    I guess the question I am asking is this:
    Is there currently any setting anywhere that would affect (or fix) this that I am overlooking?

    As Qt Creator has many settings, and some settings are only reachable via editing textual configurations or even creating files that didn't exist in the first place. So, if there is such a setting I'd be grateful to know what it is. If not, that's fine. Just wanted to reach out and let you know of my findings.

    Thank you for listening!

    I'm truly glad you r/offmychess t finally, but please don't go too far, because you r/beyondvoxels and that implies that u r/donewithlife. Oh well time to git back to the lab, because azure sea here, I have a lot of work to do...

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved