diff --git a/src/Fantomas.Tests/SynConstTests.fs b/src/Fantomas.Tests/SynConstTests.fs index 0f8d53a692..4834c786e3 100644 --- a/src/Fantomas.Tests/SynConstTests.fs +++ b/src/Fantomas.Tests/SynConstTests.fs @@ -294,3 +294,17 @@ let f (c: char) = | '\u0000' | _ -> () """ + +[] +let ``hex escape in string literal should be preserved, 1508`` () = + formatSourceString + false + """let hexEscape = "\x00" +let controlEscapes = "\a \b \f \v" +""" + config + |> should + equal + """let hexEscape = "\x00" +let controlEscapes = "\a \b \f \v" +""" diff --git a/src/Fantomas/TokenParser.fs b/src/Fantomas/TokenParser.fs index e14fe4b72b..633023253c 100644 --- a/src/Fantomas/TokenParser.fs +++ b/src/Fantomas/TokenParser.fs @@ -507,7 +507,7 @@ let private (|InterpStringEndOrPartToken|_|) token = None let escapedCharacterRegex = - System.Text.RegularExpressions.Regex("(\\\\(n|r|u|'|\\\"|\\\\))+") + System.Text.RegularExpressions.Regex("(\\\\(a|b|f|n|r|u|v|x|'|\\\"|\\\\))+") let rec private (|EndOfInterpolatedString|_|) tokens = match tokens with