Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert chain indentation in an argument list #574

Merged

Conversation

belka-ew
Copy link
Collaborator

Fixes the indentation of arguments after a function chain (see the tests for examples).

This fix works only with --single_indent=true. The reason is that function chains aren't aligned properly without --single_indent. For example the following code:

class C {
    void f()
    {
        if (true) {
            f(
                    array.map!(a => a.prop)
                        .array
                        .to!string,
                    __FILE__,
                    __LINE__);
        }
    }
}

is formatted as

class C
{
    void f()
    {
        if (true)
        {
            f(
                    array.map!(a => a.prop)
                    .array
                    .to!string,
                    __FILE__,
                    __LINE__);
        }
    }
}

So I think it is a different problem.

void f() {
if (true) {
f(map.map.map.map.map.map.map.map.map.map.map.map.map.map.map.map
.map.map.map.map.map.map, __FILE__, __FILE__, __FILE__, __FILE__, __FILE__,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be a new line after the .map,? Or at least wrap after the 3rd __FILE__ and not after the 5th (because the other lines below also wrap around that column)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is how line breaks are currently added. It was the main reason we wanted to have --keep-line-breaks, so such things can be adjusted manually because in the complicated code it is difficult to calculate the right way to add line breaks (if there is the right way).

Copy link
Member

@WebFreak001 WebFreak001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good for what it fixes

@WebFreak001 WebFreak001 merged commit a4fbc6f into dlang-community:master Jan 15, 2023
@belka-ew belka-ew deleted the bug/argument_chain_indent branch January 15, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants