Skip to content

Commit

Permalink
Indent multiline record field expressions from the opening brace.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Sep 27, 2021
1 parent fb3c595 commit 2fdf476
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 107 deletions.
47 changes: 47 additions & 0 deletions src/Fantomas.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,53 @@ let a =
B = 7 }
"""

[<Test>]
let ``comment alignment above record field`` () =
formatSourceString
false
"""
let a =
{ c = 4
// foo
// bar
B = 7 }
"""
config
|> prepend newline
|> should
equal
"""
let a =
{ c = 4
// foo
// bar
B = 7 }
"""

[<Test>]
let ``comment alignment above record field, fsharp_space_around_delimiter = false`` () =
formatSourceString
false
"""
let a =
{ c = 4
// foo
// bar
B = 7 }
"""
{ config with
SpaceAroundDelimiter = false }
|> prepend newline
|> should
equal
"""
let a =
{c = 4
// foo
// bar
B = 7}
"""

[<Test>]
let ``shouldn't break on one-line comment`` () =
formatSourceString
Expand Down
8 changes: 4 additions & 4 deletions src/Fantomas.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ let config =
#if WATCH
#else
"https://fsprojects.github.io/fantomas/"
"https://fsprojects.github.io/fantomas/"
#endif
}
"""
Expand Down Expand Up @@ -1944,7 +1944,7 @@ let config =
theme_variant = Some "red"
root_url =
#if WATCH
"http://localhost:8080/"
"http://localhost:8080/"
#else
#endif
Expand Down Expand Up @@ -1979,9 +1979,9 @@ let config =
theme_variant = Some "red"
root_url =
#if WATCH
"http://localhost:8080/"
"http://localhost:8080/"
#else
"https://fsprojects.github.io/fantomas/"
"https://fsprojects.github.io/fantomas/"
#endif
}
"""
Expand Down
32 changes: 16 additions & 16 deletions src/Fantomas.Tests/NumberOfItemsRecordTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ let myRecord =
Progress = "foo"
Bar = { Zeta = "bar" }
Address =
{ Street = "Bakerstreet"
ZipCode = "9000" }
{ Street = "Bakerstreet"
ZipCode = "9000" }
Number = 42 }
"""

Expand Down Expand Up @@ -220,8 +220,8 @@ let ``anonymous record with multiple field update`` () =
"""
let a =
{| foo with
Level = 7
Square = 9 |}
Level = 7
Square = 9 |}
"""

[<Test>]
Expand Down Expand Up @@ -272,12 +272,12 @@ let anonRecord =
"""
let anonRecord =
{| A =
{| A1 = "string"
A2LongerIdentifier = "foo" |}
{| A1 = "string"
A2LongerIdentifier = "foo" |}
B = {| B1 = 7 |}
C =
{ C1 = "foo"
C2LongerIdentifier = "bar" }
{ C1 = "foo"
C2LongerIdentifier = "bar" }
D = { D1 = "bar" } |}
"""

Expand Down Expand Up @@ -797,9 +797,9 @@ let config =
theme_variant = Some "red"
root_url =
#if WATCH
"http://localhost:8080/"
"http://localhost:8080/"
#else
"https://fsprojects.github.io/fantomas/"
"https://fsprojects.github.io/fantomas/"
#endif
}
"""
Expand Down Expand Up @@ -1036,9 +1036,9 @@ let s =
let r' =
{| r with
a = x
b = y
z = c |}
a = x
b = y
z = c |}
let s' =
{| s with AReallyLongExpressionThatIsMuchLongerThan50Characters = 1 |}
Expand All @@ -1054,9 +1054,9 @@ g s {| AReallyLongExpressionThatIsMuchLongerThan50Characters = 1 |}
f
r'
{| r with
a = x
b = y
z = c |}
a = x
b = y
z = c |}
g s' {| s with AReallyLongExpressionThatIsMuchLongerThan50Characters = 1 |}
"""
Expand Down
8 changes: 4 additions & 4 deletions src/Fantomas.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ Fooey
"
let r =
{| Foo =
a
&& // && b
c
a
&& // && b
c
Bar =
\"\"\"
\"\"\"
Fooey
\"\"\" |}
"
Expand Down
Loading

0 comments on commit 2fdf476

Please sign in to comment.