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

Leading newline because of trivia does not item multiline. #1710

Merged
merged 2 commits into from
May 9, 2021
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
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