sterpe / coffee-fmt

gofmt for coffee
MIT License
9 stars 4 forks source link

Feature Request: Option to Keep X Blank Lines #9

Open jaswrks opened 9 years ago

jaswrks commented 9 years ago

It would be really helpful if there were an option --keep-blank-lines=1; i.e., making it possible to keep X number of blank lines if desirable. I'd suggest a default value of 1 blank line is allowed.

sterpe commented 9 years ago

I think I had initially hoped to do something like this, but unfortunately the CS tokenizer gobbles up a lot of the non-significant white-space, and without a white-space and newline token it's not easily recreated. Originally I had added a newline token and was able to preserve some of the line spacing, but the inclusion of the new token was messing up the tokenizer's parsing in some situations...

I'm a bit backed up at the moment, but if you want to take a look at this problem, I'll accept a pull request.

sterpe commented 9 years ago

With v0.10.0 all the existing blank lines are now kept. I've written a new Coffeescript parser that preserves this line information so that the original source is unambiguously reconstructable. Is this something we still want to look at doing?