madlib
madlib copied to clipboard
Autoformatter with multiline / backtick-wrapped strings incorrectly formats output
import Fn from "Function"
formatMe = () => do {
input = `
yo yo yo hey nice
`
_ <- Fn.always(input)() == `
yo yo yo hey nice
`
}
On madlib format
this reformats the second string to be a single-line string with no newlines
Smaller reproduction case:
r = "" ++ `
yo yo yo hey nice
`
I'm still seeing a case on v0.23.12
where a trailing newline gets removed:
formatMe = () => {
return "" ++ `
yo yo yo hey nice
`
}
Trailing newlines get truncated by one newline on each format
import IO from "IO"
a = `
aaaaaaa
`
b = `\nbbbbbb\b`
c = ` ${b} `
main = () => {
IO.put(`${a}
${b}
${c}`)
}
☝🏼 This case is currently handled incorrectly as it smashes the three interpolated expressions together with no newline:
IO.put(`${a}${b}${c}`)
Tested on v0.23.13
The extant code in this file gets autoformatted incorrectly: https://github.com/madlib-lang/madmarkdown-parser/blob/master/src/Example.mad