haskell-formatter icon indicating copy to clipboard operation
haskell-formatter copied to clipboard

Non-ASCII characters are escaped to determine spacing

Open evolutics opened this issue 11 years ago • 1 comments

Input:

string = '☑' : " same line"

Expected output:

string = '☑' : " same line"

Actual output:

string = '☑'     : " same line"

evolutics avatar Sep 01 '14 15:09 evolutics

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"

evolutics avatar Sep 01 '14 15:09 evolutics