Skip to content

ExpressionMacro trailing closure inherits code's original indentation #2126

Open
@InkyTsar

Description

@InkyTsar

Description

If macro is nested in some closure, its trailing closure preserves the original code indentation. So if I build FunctionCallExprSyntax with trailing closure that takes statements from the original trailing closure, the new statements are incorrectly indented.

This probably applies as well to closure as last argument.

Is there any manual way to trim the statements to decrease the indent?

Steps to Reproduce

assertMacroExpansion(
    #"""
    VStack {
        #SomeMacro(arg1) { output in
            EmptyView()
        }
    }
    """#,
    expandedSource: #"""
    VStack {
        SomeWrapper(arg1) { output in
            EmptyView()
        }
    }
    """#,
    macros: testMacros
)

The code above incorrectly expands to:

    #"""
    VStack {
        SomeWrapper(arg1) { output in
                EmptyView()
        }
    }
    """#

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions