Skip to content

Expand multiline lists without expanding surrounding expression #392

@schonstal

Description

@schonstal

I use dataclass-like event objects in my current project, like so:

    EventBus.notify(node, Events.Explosion.new({
        "direction": direction, 
        "center": global_position,
    }))

I prefer to format them this way universally in my project. The only part of the expression I want to be multiline is the list that I've defined as explicitly multiline with the trailing comma.

However, if I add a trailing comma and run gdformat, it expands the entire function call to the following:

    (
        EventBus
        . notify(
            node,
            (
                Events
                . Explosion
                . new(
                    {
                        "direction": direction,
                        "center": global_position,
                    }
                )
            )
        )
    )

I don't want it to expand the rest of the expression, it's not very readable like this.

Without a trailing comma it will change the code to the following which, while better than the above, is not to my preferences:

    EventBus.notify(node, Events.Explosion.new({"direction": direction, "center": global_position}))

I'd like to be able to configure it to force expansion on the list without expanding the entire line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions