Skip to content

Commit

Permalink
Fix multiple line type expression with dotget idempotency (#3133)
Browse files Browse the repository at this point in the history
* Fix multiple line type expression with dotget idempotency

* Minor refactor

---------

Co-authored-by: nojaf <[email protected]>
  • Loading branch information
Leaxe and nojaf authored Oct 29, 2024
1 parent 06d86ad commit b7dca79
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
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

0 comments on commit b7dca79

Please sign in to comment.