Closed ErikSchierboom closed 2 months ago
I've just tried reproducing it from within a test in Fantomas, but that does work 🤔 I'll do some more digging.
Yeah, this is more or less to be expected. We don't seem to add the single quotes in https://github.com/fsprojects/fantomas/blob/4d5e5e26fbf4e0d3059bdc20453c01432c679070/src/Fantomas.Core/ASTTransformer.fs#L142
In practice, the value of SynConst.Char
is quite unreliable, so Fantomas will normally reuse the char content based on the original source code. This is why this works in the test.
let formattedCode = CodeFormatter.FormatASTAsync(tree, code) |> Async.RunSynchronously
probably would be another workaround.
I would accept a PR fix for this.
Thanks!
formatSourceString "let s = 'A'" config
|> should equal "let s = 'A'\n"
works, but
formatAST false "let s = 'A'" config
|> should equal "let s = 'A'\n"
doesn't.
I'll see if I can figure it out :)
I've opened a PR: #3077
I've been using
FormatASTAsync
to format my code, but I found out that it is removed the single quotes from characters.I've also tried:
But that has the same issue.
I'm using: