TheRealSyler / sass-formatter

Sass(indented syntax) formatter written in typescript
https://sass-formatter.syler.de
MIT License
10 stars 2 forks source link

Necessary indent removed when line ending is crlf. #35

Closed crupest closed 4 years ago

crupest commented 4 years ago

Describe the bug Some necessary indent is removed when the file's line ending is crlf. When I change it to lf, it works right. I' m not sure it is a bug of formatter or some conflict of extensions, maybe, or other things.

To Reproduce Create a file with .sass extension in name. Make sure line ending is crlf. Add following code:

@keyframes aaa
  from
    background: white
  to
    background: black

Then format, it turns to

@keyframes aaa
  from
  background: white
  to
  background: black

Undo format and change the file line ending to lf. Then format again. It remains the correct format.

Expected behavior In crlf, it should be formatted to

@keyframes aaa
  from
    background: white
  to
    background: black

Screenshots No.

Desktop (please complete the following information):

Additional context Some other extensions I used which might interfere:

(Update: I tried to disable two extensions above, the bug remained.)

Preferences related are all default.

By the way, VS Code version is 1.49.2.

TheRealSyler commented 4 years ago

@crupest i confirmed the bug, i think i just need to replace \n with \r?\n in all my regex's so this should be an easy fix.

crupest commented 4 years ago

I'm not quite familiar with formatter internals. Your fix is reasonable. I think a good start would be to write some unit tests against this, which I could help do if I have time.

And if all existing unit tests pass after your fix is applied, it might be ok!

TheRealSyler commented 4 years ago

thanks but that not necessary, i added the info as a reminder for me so that i know what i have to do.

crupest commented 4 years ago

That would be nice then! Thank you for your devotion!😁

TheRealSyler commented 4 years ago

@crupest it works now in the formatter i just need to update the extension, im not sure if i can use the line endings from vscode or if you have to select the line ending manually in any case new version should be up in a less that a hour.

crupest commented 4 years ago

It would be better if formatter could keep the original line ending. So I think it is not necessary to use it from vscode as long as vscode passes the original line ending to extension. Whatever, giving the correct format is more important and line ending change is trivial, whose only concern is unnecessary change in git history.