Skip to content

Commit

Permalink
Delete spaces for named arguments (#2038)
Browse files Browse the repository at this point in the history
* delete spaces for named arguments

* restore space for multiline function argument

* delete spaces for PatWithIdent

* fix build

* restore spaces

* revert changes for CodePrinter.fs

Co-authored-by: Florian Verdonck <[email protected]>
  • Loading branch information
Viridovics and nojaf authored Feb 11, 2022
1 parent 6e88224 commit 19c88db
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Fantomas.Tests/AppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -751,3 +751,31 @@ x |> f<y> // some comment
"""
x |> f<y> // some comment
"""

[<Test>]
let ``single named arguments should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let makeStreamReader x = new System.IO.StreamReader(path=x)"""
config
|> prepend newline
|> should
equal
"""
let makeStreamReader x = new System.IO.StreamReader(path = x)
"""

[<Test>]
let ``multiple named arguments should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let makeStreamReader x y = new StreamReader(arg1=x, arg2=y)"""
config
|> prepend newline
|> should
equal
"""
let makeStreamReader x y = new StreamReader(arg1 = x, arg2 = y)
"""
20 changes: 20 additions & 0 deletions src/Fantomas.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2047,3 +2047,23 @@ match!
| None -> false
| Some balance -> someRetrievedBalance = balance
"""

[<Test>]
let ``single line named fields in a pattern matching should have space surrounding the '=', 1877`` () =
formatSourceString
false
"""
let examineData x =
match data with
| OnePartData(part1 = p1) -> p1
| TwoPartData(part1 = p1; part2=p2) -> p1 + p2"""
config
|> prepend newline
|> should
equal
"""
let examineData x =
match data with
| OnePartData (part1 = p1) -> p1
| TwoPartData (part1 = p1; part2 = p2) -> p1 + p2
"""

0 comments on commit 19c88db

Please sign in to comment.