humio / atom-elm-format

Run elm-format in atom
https://atom.io/packages/elm-format
Apache License 2.0
10 stars 8 forks source link

Use onWillSave, spawnSync, setTextViaDiff #14

Closed halohalospecial closed 8 years ago

halohalospecial commented 8 years ago

Hi! Currently, those using linter-elm-make are having issues when they have elm-format installed. It's because elm-format is saving the file again, resulting to 2 lints. There's an elm-make bug that's causing warnings to disappear in linter-elm-make when the file is saved another time without changes.

This PR tries to remedy the issue by formatting the text in onWillSave instead of onDidSave. It also needed the operation to be synchronous, therefore spawnSync was used. Finally, setTextViaDiff was used to remove the flicker caused by syntax highlighting computation.

References: https://github.com/elm-lang/elm-make/issues/114 https://github.com/mybuddymichael/linter-elm-make/issues/81

Sorry if the changes are quite significant. I'll perfectly understand if you will not accept the PR since it will change the current behavior of elm-format.

Thanks!

benjick commented 8 years ago

Thank you! I will try to test this out tomorrow.

I think accommodating for the linter is the right move

benjick commented 8 years ago

Could you also remove commented code that's not used and amend that?

halohalospecial commented 8 years ago

Sorry, I'm using my phone right now. I can change it tomorrow.

halohalospecial commented 8 years ago

Hi @benjick, I already removed the commented code. Thanks!

benjick commented 8 years ago

Thanks again @halohalospecial, I've published this now!

halohalospecial commented 8 years ago

Thanks @benjick @floriangrundig !