haskell-formatter
haskell-formatter copied to clipboard
Non-ASCII characters are escaped to determine spacing
Input:
string = '☑' : " same line"
Expected output:
string = '☑' : " same line"
Actual output:
string = '☑' : " same line"
This has to do with how the actual code is formatted by FormatActualCode. The function prettyPrintStyleMode of HSE escapes non-ASCII characters. To prevent this escaping while still reusing its functionality, the structure of the syntax tree is kept, but its location information is replaced by the one from pretty printing.
In the example,
string = '☑' : " same line"
is pretty printed by prettyPrintStyleMode as
string = '\9745' : " same line"
where the pieces of actual code are replaced to eventually gain
string = '☑' : " same line"