Skip to content

Commit

Permalink
Add SynPat.Const as trivia node option for Number trivia. Fixes #995. (
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Aug 13, 2020
1 parent 0c436e3 commit ee6dd12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Fantomas.Tests/SynConstTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,19 @@ Target.runOrDefault "CheckCodeFormat"
Target.runOrDefault "CheckCodeFormat"
"""

[<Test>]
let ``hexadecimal numbers in match clause should be preserved, 995`` () =
formatSourceString false """
let f (a: int) =
match a, b with
| 0x55 -> Some ()
| _ -> None
""" config
|> prepend newline
|> should equal """
let f (a: int) =
match a, b with
| 0x55 -> Some()
| _ -> None
"""
1 change: 1 addition & 0 deletions src/Fantomas/Trivia.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let private findConstNodeOnLineAndColumn (nodes: TriviaNodeAssigner list) line c
|> List.tryFind (fun tn ->
match tn.Type, line = tn.Range.StartLine, column = tn.Range.StartColumn with
| MainNode("SynExpr.Const"), true, true -> true
| MainNode("SynPat.Const"), true, true -> true
| _ -> false
)

Expand Down

0 comments on commit ee6dd12

Please sign in to comment.