From ee6dd12a49938b6d17fa7b5e85ef5e908aff1034 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Thu, 13 Aug 2020 11:57:58 +0200 Subject: [PATCH] Add SynPat.Const as trivia node option for Number trivia. Fixes #995. (#997) --- src/Fantomas.Tests/SynConstTests.fs | 16 ++++++++++++++++ src/Fantomas/Trivia.fs | 1 + 2 files changed, 17 insertions(+) diff --git a/src/Fantomas.Tests/SynConstTests.fs b/src/Fantomas.Tests/SynConstTests.fs index 1afb63a0c3..8580fa723b 100644 --- a/src/Fantomas.Tests/SynConstTests.fs +++ b/src/Fantomas.Tests/SynConstTests.fs @@ -157,3 +157,19 @@ Target.runOrDefault "CheckCodeFormat" Target.runOrDefault "CheckCodeFormat" """ + +[] +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 +""" diff --git a/src/Fantomas/Trivia.fs b/src/Fantomas/Trivia.fs index 389050fa5d..5dd0308905 100644 --- a/src/Fantomas/Trivia.fs +++ b/src/Fantomas/Trivia.fs @@ -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 )