rokucommunity / brighterscript-formatter

A code formatter for BrighterScript (and BrightScript)
MIT License
15 stars 5 forks source link

Auto-formatting breaking "for" loop that contains a minus sign #48

Closed luis-soares-sky closed 2 years ago

luis-soares-sky commented 2 years ago

Versions affected: >= 2.26.0

We use the "editor.formatOnSave": true,. When saving, spaces are getting obliterated, which results in invalid code.

ezgif com-gif-maker

markwpearce commented 2 years ago

Thanks for finding this... I'll look into it, because I was the one that broke it.

I think the correct formatting for this should be:

for i = -buffer to buffer
  ' code
end for

Does that sound good to you?

luis-soares-sky commented 2 years ago

Yep, that sounds good. Thank you!

Fwiw, we've been seeing some other cases involving minus signs working correctly, so the one I described above seems to be a lone quirky edge case.

image

luis-soares-sky commented 2 years ago

Also, apologies, I opened this in the wrong repo... meant to open on https://github.com/rokucommunity/vscode-brightscript-language. 🤦‍♂️

markwpearce commented 2 years ago

@luis-soares-sky - Actually it should be in https://github.com/rokucommunity/brighterscript-formatter

TwitchBronBron commented 2 years ago

I'll move it now.

TwitchBronBron commented 2 years ago

Fixed by #49