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

erlfmt_format: dont group pipes so they all break together #84

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

awalterschulze
Copy link
Contributor

Fixes #53

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 31, 2020
'|' ->
with_next_break_fits(IsNextBreakFits, RightD, fun (R) ->
RightOpD = nest(break(concat(<<" ">>, OpD), R), Indent, break),
concat(LeftD, concat(maybe_force_breaks(HasBreak), RightOpD))
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this would behave correctly with mixed operators. For example something like 1 + 2 | 3 + 4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be a parse error "1 + 2 | 3 + 4\n" and "Foo = 1 + 2 | 3 + 4\n"
I didn't know you could write that, do you have a parsable example?

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry. This should be a complete example that parses fine today:

-type foo() :: 1 + 2 | 3 + 4.

Copy link
Contributor Author

@awalterschulze awalterschulze Aug 3, 2020

Choose a reason for hiding this comment

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

These both work

?assertSame("-type foo() :: 1 + 2 | 3 + 4.\n"),
?assertSame(
    "-type foo() ::\n"
    "    1 + 2 |\n"
    "    3 + 4.\n"
).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could add this one as a test

?assertSame(
    "-type foo() ::\n"
    "    1 + 2 |\n"
    "    3 + 4.\n"
).

But maybe you have a different test in mind?

Copy link
Member

Choose a reason for hiding this comment

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

Looks good. It seems the thing I was worried about works correctly. Great job!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got Lucky :)

@awalterschulze awalterschulze merged commit 7baebc6 into master Aug 4, 2020
@michalmuskala michalmuskala deleted the groupppipes branch August 4, 2020 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typespec variants not kept on separate lines
3 participants