From e381778bcf97ca53f532d2b05a1c44e61549c1a1 Mon Sep 17 00:00:00 2001 From: nojaf Date: Sat, 5 Mar 2022 20:57:51 +0100 Subject: [PATCH] Add regression test for in keyword in SynExpr.LetOrUse. Fixes #1182. --- CHANGELOG.md | 1 + src/Fantomas.Tests/LetBindingTests.fs | 39 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 157d518134..45bbcbfb1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Comment after equals is remove in anonymous record. [#1921](https://github.com/fsprojects/fantomas/issues/1921) * Comment after equals in record type is lost. [#2001](https://github.com/fsprojects/fantomas/issues/2001) * Comment after match keyword is lost. [#1851](https://github.com/fsprojects/fantomas/issues/1851) +* Preserve in keyword on next line. [#1182](https://github.com/fsprojects/fantomas/issues/1182) ## [4.7.0] - 2022-03-04 diff --git a/src/Fantomas.Tests/LetBindingTests.fs b/src/Fantomas.Tests/LetBindingTests.fs index fcb694d903..85a49b638b 100644 --- a/src/Fantomas.Tests/LetBindingTests.fs +++ b/src/Fantomas.Tests/LetBindingTests.fs @@ -1959,3 +1959,42 @@ let v = let formatted = formatSourceString false sourceCode config formatted |> should not' (equal EmptyString) + +[] +let ``in keyword in SynExpr.LetOrUse, 1182`` () = + formatSourceString + false + """ +do + let _ = () + in + () // note the different indent is allowed here due to `in` use + +let escapeEarth myVelocity mySpeed = + let + escapeVelocityInKmPerSec = 11.186 + in + if myVelocity > escapeVelocityInKmPerSec then + "Godspeed" + elif mySpeed == orbitalSpeedInKmPerSec then + "Stay in orbit" + else + "Come back" +""" + config + |> prepend newline + |> should + equal + """ +do let _ = () in () // note the different indent is allowed here due to `in` use + +let escapeEarth myVelocity mySpeed = + let escapeVelocityInKmPerSec = 11.186 in + + if myVelocity > escapeVelocityInKmPerSec then + "Godspeed" + elif mySpeed == orbitalSpeedInKmPerSec then + "Stay in orbit" + else + "Come back" +"""