Skip to content

Stroustrup formatting is broken for nested ifs with comments  #605

Open
@ArthaTi

Description

@ArthaTi
void main() {
    if (true) {
        if (true) { 
        }
        // This comment breaks formatting of the next line:
        else { 
        }
    }
    // Formatting below is OK
    else {
    }
}

Running dfmt --brace_style stroustrup on this file will outdent the first line with else on it. The issue does not occur on the other else, or if there isn't a comment before the else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions