rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Formatter is inserting blank lines in multiline strings on each format

Open jquesada2016 opened this issue 2 years ago • 4 comments

Thank you for filing! Check list:

  • [x] Concise, focused, friendly issue title & description.
  • [x] Is it a bug? Usage questions should often be asked in the forum instead.
  • [x] A minimal, reproducible example.
  • [x] OS and browser versions, if relevant.
  • [ ] Is it already fixed in master? Instructions

Description

Having a multiline strin causes the formatter to insert blank lines above an below each line on each an every file format.

Example

Given the following example:

let s = `
  1
  2
  3
`

On the first format call, this becomes:

let s = `

  1
  
  2
  
  3
  
`

On the second:

let s = `


  1



  2



  3


...etc

Version

  • OS: Windows 11
  • Rescript: 11.0.0-rc.7

Additional Context

As I was writing this issue, I noticed this does not happen with npx rescript format, only when issuing a format call from the IDE, VS Code in my case with the official rescript plugin.

jquesada2016 avatar Dec 13 '23 23:12 jquesada2016

This has to do with the editor line ending settings. Try changing that.

zth avatar Dec 14 '23 05:12 zth

@zth Switching from CRLF to LF did seem to fix it, although this probably should still be marked as a bug?

jquesada2016 avatar Dec 14 '23 17:12 jquesada2016