Skip to content

Commit

Permalink
Leading newline because of trivia does not item multiline. (#1710)
Browse files Browse the repository at this point in the history
* Leading newline because of trivia does not item multiline. Fixes #1709.

* Add release notes for 4.5.0-alpha-016.
  • Loading branch information
nojaf authored May 9, 2021
1 parent 768402e commit f10b822
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 6 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 4.5.0-alpha-016 - 05/2021

* Fix Unexpected newline after inner let binding. [#1709](https://github.com/fsprojects/fantomas/issues/1709)

### 4.5.0-alpha-015 - 05/2021

* Fix Currying a pair gets spread over multiple lines. [#1700](https://github.com/fsprojects/fantomas/issues/1700)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
<Version>4.5.0-alpha-015</Version>
<Version>4.5.0-alpha-016</Version>
<NoWarn>FS0988</NoWarn>
<WarningsAsErrors>FS0025</WarningsAsErrors>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.CoreGlobalTool/Fantomas.CoreGlobalTool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RollForward>Major</RollForward>
<ToolCommandName>fantomas</ToolCommandName>
<PackAsTool>True</PackAsTool>
<Version>4.5.0-alpha-015</Version>
<Version>4.5.0-alpha-016</Version>
<AssemblyName>fantomas-tool</AssemblyName>
<WarningsAsErrors>FS0025</WarningsAsErrors>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Extras/Fantomas.Extras.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>4.5.0-alpha-015</Version>
<Version>4.5.0-alpha-016</Version>
<Description>Utility package for Fantomas</Description>
<WarningsAsErrors>FS0025</WarningsAsErrors>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
Expand Down
35 changes: 35 additions & 0 deletions src/Fantomas.Tests/ColMultilineItemTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,38 @@ let blah<'a> config : Type =
let result = Runner.Run<'a> config
()
"""

[<Test>]
let ``leading newline because of trivia does not item multiline, 1709`` () =
formatSourceString
false
"""
[<Fact>]
let ``first lamba`` () =
// You can use the `fun` keyword to write lambda's.
// Mind the -> instead of C#'s =>
// TODO: complete the lambda so that the value is returned in uppercase.
let toUpperCase = fun a -> a
// ref: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword
let name = "Joey"
let uppercased = toUpperCase name
Assert.Equal("JOEY", uppercased)
"""
config
|> prepend newline
|> should
equal
"""
[<Fact>]
let ``first lamba`` () =
// You can use the `fun` keyword to write lambda's.
// Mind the -> instead of C#'s =>
// TODO: complete the lambda so that the value is returned in uppercase.
let toUpperCase = fun a -> a
// ref: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword
let name = "Joey"
let uppercased = toUpperCase name
Assert.Equal("JOEY", uppercased)
"""
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/Fantomas.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>4.5.0-alpha-015</Version>
<Version>4.5.0-alpha-016</Version>
<NoWarn>FS0988</NoWarn>
<TargetFramework>net5.0</TargetFramework>
<WarningsAsErrors>FS0025</WarningsAsErrors>
Expand Down
3 changes: 2 additions & 1 deletion src/Fantomas/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,8 @@ let private isMultilineItem (expr: Context -> Context) (ctx: Context) : bool * C
// filter leading newlines and trivia
match Array.head events with
| CommentOrDefineEvent _
| WriteLine -> true
| WriteLine
| WriteLineBecauseOfTrivia -> true
| _ -> false
else
false)
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas/Fantomas.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>4.5.0-alpha-015</Version>
<Version>4.5.0-alpha-016</Version>
<Description>Source code formatter for F#</Description>
<WarningsAsErrors>FS0025</WarningsAsErrors>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
Expand Down

0 comments on commit f10b822

Please sign in to comment.