Menu

#586 AStyle 3.6.7: wrong indentation of multi-line assignment

closed-fixed
None
2025-03-26
2025-02-28
Zenju
No

AStyle 3.6.7 produces: (full repro when inside .cpp file)

std::pair<Zstring, ComPtr<IShellItem>> getShellComputerFolder()
{
    return {displayName, computerFolder};
}


struct GetItemDetails
{
    struct Result
    {
        std::wstring objectId;
    };
    Result operator()() const
    {
        MtpTraverser::MtpItemDetails details = MtpTraverser::getThreadLocalInstance(mtpPath_.deviceDisplayName).
        getItemDetails(objectId_, mtpPath_.itemPath);
        return {objectId_};
    }
};

The expected indentation before "return" should be:

    Result operator()() const
    {
        MtpTraverser::MtpItemDetails details = MtpTraverser::getThreadLocalInstance(mtpPath_.deviceDisplayName).
                                               getItemDetails(objectId_, mtpPath_.itemPath);
        return {objectId_};
    }

using

--style=allman
--suffix=none
--keep-one-line-blocks
--align-pointer=type
--min-conditional-indent=0
--max-continuation-indent=80
--indent-switches
--indent-col1-comments
--indent-preproc-block
--indent-preproc-define
--pad-header
--pad-comma
--formatted
--lineend=linux
--indent-preproc-block
--convert-tabs
--preserve-ws

Discussion

  • André Simon

    André Simon - 2025-02-28
    • status: open --> open-accepted
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2025-03-13

    I have pushed a fix in the git repo.

     
    • Zenju

      Zenju - 2025-03-14

      It works! :)

      BTW thanks for supporting all these different build environments: I downloaded the latest Astyle code from git, opened the vs2022 solution, just compiled: executable built, no errors! My mind is a bit blown by how great this works and how easys it is. I didn't even have to read any documentation, or fiddle with compiler options. It' s like when you're used to torture, but then you're unexpectedly offered a spa...

       
  • André Simon

    André Simon - 2025-03-16

    I have reverted this fix as it was based on a wrong assumption... the problem is the template earlier which triggers the indent in the unrelated code later.

    Well back in the day it was no rocket science to compile something which had no third party dependencies. Simple things should be kept simple ;)

     
  • André Simon

    André Simon - 2025-03-20

    I have pushed another variant of the fix.

     
  • Zenju

    Zenju - 2025-03-21

    Thank you! :) Ticket can be closed.

     
  • André Simon

    André Simon - 2025-03-26
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →