Skip to content

Commit

Permalink
Use atCurrentColumn for pattern in match clause. (#2671)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Dec 28, 2022
1 parent 13739df commit 37a34fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion src/Fantomas.Core.Tests/PatternMatchingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ let examineData x =
match data with
| OnePartData( // foo
part1 = p1
(* bar *) ) -> p1
(* bar *) ) -> p1
| TwoPartData(part1 = p1; part2 = p2) -> p1 + p2
"""

Expand Down Expand Up @@ -2292,3 +2292,28 @@ line3
inputB -> \"InputB=\" + inputB
| _ -> failwith \"Invalid query\"
"

[<Test>]
let ``trivia in list cons pattern, 1939`` () =
formatSourceString
false
"""
let f () =
match lines with
| head ::
// Comment
tail -> 1
| _ -> None
"""
config
|> prepend newline
|> should
equal
"""
let f () =
match lines with
| head ::
// Comment
tail -> 1
| _ -> None
"""
2 changes: 1 addition & 1 deletion src/Fantomas.Core/CodePrinter2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2585,7 +2585,7 @@ let genPatInClause (pat: Pattern) =
+> sepSpace
+> genPat p.RightHandSide

| p -> genPat p
| p -> atCurrentColumn (genPat p)

genPatMultiline pat

Expand Down

0 comments on commit 37a34fd

Please sign in to comment.