Menu

#585 AStyle 3.6.7: class modifiers indentation

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

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

struct Win32Traverser
{
    class DirReader
    {
        public:
        explicit DirReader(const Zstring& dirPath)
        {
        }

private:
        WIN32_FIND_DATA data_;
        bool haveFirstData_ = false;
    };
};

The "public" should be indented one tab less, the "private" one tab more.

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

Thanks so much for your continuing support of the best C++ code formatter! (leaving others like clang-format in the dust!)

Discussion

  • André Simon

    André Simon - 2025-02-28

    Hi, this is a known bug I will tackle next. structs are a bit tricky for astyle.

    clang-format has more advanced insight into the code structure, but still lacks some astyle features ;)

     
  • 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! :)

     
  • Zenju

    Zenju - 2025-03-14

    Unfortunately this example doesn't work yet:

    namespace
    {
    struct SshDeviceId
    {
    };
    
    class SftpSessionManager
    {
    public:
        class SshSessionShared
        {
            public:
            SshSessionShared() :
        session_(0) {}
    
        int session_;
        };
    }
    }
    

    should be

    namespace
    {
    struct SshDeviceId
    {
    };
    
    class SftpSessionManager
    {
    public:
        class SshSessionShared
        {
        public:
            SshSessionShared() :
                session_(0) {}
    
            int session_;
        };
    }
    }
    
     
  • André Simon

    André Simon - 2025-03-16

    Hi, I pushed another fix

     
  • Zenju

    Zenju - 2025-03-17

    This is a major improvement! Most issues are gone, but not the following:

    class GdriveFileState
    {
    public:
        std::optional<std::vector<int>> tryGetBufferedFolderContent()
        {
            return {};
        }
    
        struct FileStateDelta
        {
            FileStateDelta() {}
    private:
            int test = 0;
        };
    };
    
     
  • Zenju

    Zenju - 2025-03-17

    Here's a probably related issue with function "missingIndent()":

    void test(const std::vector<std::pair<int, int>>& workload)
    {
    }
    
    class NativeFileSystem
    {
    public:
    Zstring missingIndent() const { return isNullFileSystem() ? Zstring{} : rootPath_; }
    };
    
     
  • André Simon

    André Simon - 2025-03-20

    Please try again with the latest version in git.

     
  • Zenju

    Zenju - 2025-03-21

    Awesome! I seem to have run out of any more of these issues :D The ticket can probably be closed.

     
  • André Simon

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

Log in to post a comment.