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

Fix array literal indentation in foreach #554

Merged
merged 2 commits into from
Jun 14, 2022

Conversation

belka-ew
Copy link
Collaborator

@belka-ew belka-ew commented Jun 3, 2022

This is a more generic fix for the array indentation problems in parens. It was already fixed for array literals in function arguments, but there are other places it still didn't work. e.g. foreach statements.

Here is the old formatting with --keep_line_breaks:

    foreach (x; [
        1,
        2,
        3,
        ])
    {
    }

With this change the formatting is:

    foreach (x; [
        1,
        2,
        3,
    ])
    {
    }

It also fixes the formatting of the last example in this issue #435.

And I changed test.sh to ignore test.d, because currently test.sh is broken.

Copy link
Contributor

@maxhaton maxhaton left a comment

Choose a reason for hiding this comment

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

LGTM, not very familiar with this code though

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.

void f()
{
    foreach (x; foo!(map!([
            1,
            2,
            3,
        ])))
    {
    }

still gets formatted like this, intended?

@belka-ew
Copy link
Collaborator Author

belka-ew commented Jun 8, 2022

still gets formatted like this, intended?

No. Fixed and tests added.

@belka-ew belka-ew requested a review from WebFreak001 June 14, 2022 05:58
@WebFreak001 WebFreak001 merged commit d862d8a into dlang-community:master Jun 14, 2022
veelo pushed a commit to veelo/dfmt that referenced this pull request Jul 11, 2022
@belka-ew belka-ew deleted the bug/foreach-array branch July 24, 2022 12:44
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.

3 participants