Skip to content

clang-format: better continuation indent options for BraceWrapping=false #135269

Open
@belm0

Description

@belm0

With BraceWrapping set to false, readability is impacted when the opening of a code block includes continuation indents, causing the continued lines and the first line of the body to have the same indent level:

Foo::Bar::Result<Foo::Bar::Type1, Foo::Bar::Type2> exampleFunction(
    const SomeType& arg1, const AnotherType& arg2) {
    auto variable = someValue;
    ...

I'd like the continuations to be double-indented, but ContinuationIndentWidth is coarse and applies to too may cases where I don't want additional indent (function calls, etc.).

So perhaps add an option like UnwrappedBraceContinuationIndent that will apply to continued lines prior to an unwrapped brace.

// with UnwrappedBraceContinuationIndent: 8

Foo::Bar::Result<Foo::Bar::Type1, Foo::Bar::Type2> exampleFunction(
        const SomeType& arg1, const AnotherType& arg2) {
    auto variable = someValue;
    auto another_var = very_long_function_call(const Baz& arg1, const Baz& arg2,
        const Baz& arg3);   // NOTE: regular continuation indent
    ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions