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

Keep Subsequent identifier links on the same line. #2713

Merged
merged 3 commits into from
Jan 14, 2023

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented Jan 13, 2023

Fixes #2712.

@nojaf nojaf requested a review from dawedawe January 13, 2023 17:33
"""

[<Test>]
let ``very long chain with a some index expressions`` () =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dawedawe this one is a bit tricky. The whole chain does not fit within the MaxDotGetExpressionWidth boundary, but there is no application to chop it logically.

@@ -1123,7 +1129,7 @@ let genExpr (e: Expr) =
short
(match leadingChain with
| [] -> sepNone
| head :: links -> genFirstLinkAndIndentOther head links)
| head :: links -> genLink false head +> indent +> genIndentedLinks true links +> unindent)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dawedawe I changed the implementation to only consider the max_line_length when there are only simple links in the chain.

You basically print the first one, if the second fits after it, great, if not put it on the next line. I think this is reasonable.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, very reasonable.

@@ -1123,7 +1129,7 @@ let genExpr (e: Expr) =
short
(match leadingChain with
| [] -> sepNone
| head :: links -> genFirstLinkAndIndentOther head links)
| head :: links -> genLink false head +> indent +> genIndentedLinks true links +> unindent)
Copy link
Member

Choose a reason for hiding this comment

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

Yep, very reasonable.

src/Fantomas.Core.Tests/ChainTests.fs Outdated Show resolved Hide resolved
@nojaf nojaf merged commit 0d0cab0 into fsprojects:main Jan 14, 2023
@nojaf nojaf deleted the fix-duck-duck-goose branch January 14, 2023 09:33
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.

Subsequent identifier links in chain should be on the same line
2 participants