madlib icon indicating copy to clipboard operation
madlib copied to clipboard

Autoformatter with multiline / backtick-wrapped strings incorrectly formats output

Open brekk opened this issue 10 months ago • 4 comments

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

brekk avatar Apr 14 '24 06:04 brekk

Smaller reproduction case:

r = "" ++ `
  yo yo yo hey nice
`

aboeglin avatar Apr 20 '24 19:04 aboeglin

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

brekk avatar Apr 22 '24 07:04 brekk

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

brekk avatar May 06 '24 17:05 brekk

The extant code in this file gets autoformatted incorrectly: https://github.com/madlib-lang/madmarkdown-parser/blob/master/src/Example.mad

brekk avatar May 10 '24 20:05 brekk