Skip to content

Commit b7dca79

Browse files
Leaxenojaf
andauthored
Fix multiple line type expression with dotget idempotency (#3133)
* Fix multiple line type expression with dotget idempotency * Minor refactor --------- Co-authored-by: nojaf <florian.verdonck@outlook.com>
1 parent 06d86ad commit b7dca79

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Changelog
22

3+
## 6.3.16 - 2024-10-29
4+
5+
### Fixed
6+
* Idempotency problem when calling multi-line discriminated union with generic type parameter. [#3132](https://github.com/fsprojects/fantomas/issues/3132)
7+
38
## 6.3.15 - 2024-09-14
49

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

813
## 6.3.14 - 2024-09-14
914

src/Fantomas.Core.Tests/ChainTests.fs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,29 @@ v().w.x.y.z['a'].b
414414
"""
415415
v().w.x.y.z['a'].b
416416
"""
417+
418+
[<Test>]
419+
let ``multiple line type expression with dotget, 3132`` () =
420+
formatSourceString
421+
"""
422+
Animal<
423+
Identifier
424+
>
425+
.Dog(
426+
"Spot"
427+
)
428+
"""
429+
{ config with
430+
MaxDotGetExpressionWidth = 0
431+
MaxLineLength = 10 }
432+
|> prepend newline
433+
|> should
434+
equal
435+
"""
436+
Animal<
437+
Identifier
438+
>
439+
.Dog(
440+
"Spot"
441+
)
442+
"""

src/Fantomas.Core/CodePrinter.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,9 @@ let genExpr (e: Expr) =
10141014
(coli sepNone leadingChain (fun idx -> genLink (idx = lastIndex)))
10151015
(match leadingChain with
10161016
| [] -> sepNone
1017-
| head :: rest -> genLink false head +> indentSepNlnUnindent (genIndentedLinks false rest))
1018-
+> indentSepNlnUnindent (genIndentedLinks false links)
1017+
| [ head ] -> genLink false head
1018+
| head :: rest -> genLink false head +> indentSepNlnUnindent (genIndentedLinks true rest))
1019+
+> indentSepNlnUnindent (genIndentedLinks true links)
10191020

10201021
| head :: links -> genFirstLinkAndIndentOther head links
10211022

0 commit comments

Comments
 (0)