Skip to content

Commit

Permalink
Adding 0 to be recognized as one of the escaped characters. (#2051)
Browse files Browse the repository at this point in the history
* Adding 0 to be recognized as one of the escaped characters.

* Simplifying unit test for string with null character.

Co-authored-by: Dominik Skoda <[email protected]>
Co-authored-by: DS185357 <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2022
1 parent 503a471 commit dfaf07d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Fantomas.Tests/StringTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,8 @@ let s =
\"\"\"aaaa
bbb\"\"\"
"

[<Test>]
let ``unicode null character should be recognized as a trivia item, 2050`` () =
formatSourceString false "let s = \"\\000\"" config
|> should equal "let s = \"\\000\"\n"
2 changes: 1 addition & 1 deletion src/Fantomas/TokenParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ let private (|InterpStringEndOrPartToken|_|) token =
None

let escapedCharacterRegex =
System.Text.RegularExpressions.Regex("(\\\\(a|b|f|n|r|t|u|v|x|'|\\\"|\\\\))+")
System.Text.RegularExpressions.Regex("(\\\\(a|b|f|n|r|t|u|v|x|0|'|\\\"|\\\\))+")

let private (|MultipleStringTextTokens|_|) tokens =
let f _ =
Expand Down

0 comments on commit dfaf07d

Please sign in to comment.