urbanopt / modelica-fmt

BSD 3-Clause "New" or "Revised" License
20 stars 6 forks source link

Prevent file modification if formatter runs into an error #34

Open Ashwin-Hariharan0 opened 2 weeks ago

Ashwin-Hariharan0 commented 2 weeks ago

When -w argument is used and formatter runs into "token recognition error", the .mo file is incorrectly modified. Could the formatter behavior be changed so that .mo file is overwritten only if there are no errors encountered (and leave modelica files which contain unrecognized tokens untouched)?

image

tpwo commented 2 weeks ago

I see you have a fresh account, so you might not know that overusing @ to mention people on GitHub is a misbehavior. All people currently involved in the development should receive notifications anyway.

I'm not this kind of person, and I haven't used the Modelica language for over two years at this point, not mentioning this formatter.

I'm not sure if this project is still maintained. At the same time, I know that my former colleague created an alternative Modelica formatter which you may consider: https://github.com/ErykMroczek/mofmt

Note that I don't know which one is better or if there are any differences in offered features.

Ashwin-Hariharan0 commented 2 weeks ago

My apologies Tomasz, I'll remove the @ mentions (I wasn't sure if this repo was being actively tracked, so added a few people from the parent org).

Thank you for your recommendation of the alternative formatter, I will test it out.

nllong commented 2 weeks ago

We still use and develop this formatter and have not seen this error, can you share your .mo file that you are trying to format?