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 multiple line type expression with dotget idempotency #3133

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Changelog

## 6.3.16 - 2024-10-29

### Fixed
* Idempotency problem when calling multi-line discriminated union with generic type parameter. [#3132](https://github.com/fsprojects/fantomas/issues/3132)

## 6.3.15 - 2024-09-14

### Fixed
* Non needed parentheses are added around lambda call from tuple/members [#3082](https://github.com/fsprojects/fantomas/issues/3082)
* Non needed parentheses are added around lambda call from tuple/members. [#3082](https://github.com/fsprojects/fantomas/issues/3082)

## 6.3.14 - 2024-09-14

Expand Down
26 changes: 26 additions & 0 deletions src/Fantomas.Core.Tests/ChainTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,29 @@ v().w.x.y.z['a'].b
"""
v().w.x.y.z['a'].b
"""

[<Test>]
let ``multiple line type expression with dotget, 3132`` () =
formatSourceString
"""
Animal<
Identifier
>
.Dog(
"Spot"
)
"""
{ config with
MaxDotGetExpressionWidth = 0
MaxLineLength = 10 }
|> prepend newline
|> should
equal
"""
Animal<
Identifier
>
.Dog(
"Spot"
)
"""
5 changes: 3 additions & 2 deletions src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,9 @@ let genExpr (e: Expr) =
(coli sepNone leadingChain (fun idx -> genLink (idx = lastIndex)))
(match leadingChain with
| [] -> sepNone
| head :: rest -> genLink false head +> indentSepNlnUnindent (genIndentedLinks false rest))
+> indentSepNlnUnindent (genIndentedLinks false links)
| [ head ] -> genLink false head
| head :: rest -> genLink false head +> indentSepNlnUnindent (genIndentedLinks true rest))
+> indentSepNlnUnindent (genIndentedLinks true links)

| head :: links -> genFirstLinkAndIndentOther head links

Expand Down
Loading