Skip to content

Commit

Permalink
Print trivia for SynExpr.Paren in alternate style. Fixes fsprojects#1276
Browse files Browse the repository at this point in the history
.
  • Loading branch information
nojaf committed Apr 4, 2021
1 parent 4a46421 commit c8f0f52
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Fantomas.Tests/AppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,49 @@ module SomeModule =
initialAbs / 100
"""

[<Test>]
let ``comment after app with single tuple arg, 1276`` () =
formatSourceString
false
"""
SomeFunction(arg1,
arg2,
arg3) // does something
SomeOtherFunction(arg1, arg2) // does another thing
"""
config
|> prepend newline
|> should
equal
"""
SomeFunction(arg1, arg2, arg3) // does something
SomeOtherFunction(arg1, arg2) // does another thing
"""

[<Test>]
let ``comment after app with single tuple arg, multiline format`` () =
formatSourceString
false
"""
SomeFunction(arg1,
arg2,
arg3) // does something
SomeOtherFunction(arg1, arg2) // does another thing
"""
{ config with MaxLineLength = 20 }
|> prepend newline
|> should
equal
"""
SomeFunction(
arg1,
arg2,
arg3
) // does something
SomeOtherFunction(
arg1,
arg2
) // does another thing
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2849,6 +2849,7 @@ and genMultilineFunctionApplicationArguments sepOpenTFor sepCloseTFor astContext
+> unindent
+> sepNln
+> sepCloseTFor rpr pr
|> genTriviaFor SynExpr_Paren pr

let genExpr astContext e =
match e with
Expand Down

0 comments on commit c8f0f52

Please sign in to comment.