sorawee / fmt

A code formatter for Racket
Other
72 stars 6 forks source link

formatting of here strings results in syntax error. #32

Closed masukomi closed 2 years ago

masukomi commented 2 years ago

given the following code, the trailing HERE that closes the "here string" will not be left on a line by itself. Instead the paren after it will be moved up, which makes the HERE not end the string, which makes a syntax error for the rest of the file.

The temporary workaround is to add a comment on a line AFTER the end of string indicator and before the next parentheses.

(string->jsexpr
    #<<HERE
 {
  "foo": "bar"
}
HERE
    )

that gets transformed to end with HERE) which breaks things.

To workaround the problem:

(string->jsexpr
    #<<HERE
 {
  "foo": "bar"
}
HERE
; formatter break
    )

the expected/correct behavior is to leave the closing of the here string on the line by itself and then on the following line close/open any parentheses at the same level of indentation that the "here string" began at.

sorawee commented 2 years ago

Thanks for the report!