atom-haskell / ide-haskell

Haskell IDE plugin for Atom editor

Home Page:https://atom.io/packages/ide-haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prettifier on Save rewrite of the file erases IDE-Haskell compiler errors

cscalfani opened this issue · comments

I have Prettify on Save and the compiler errors show up for just a second in the lower pane and then disappears.

Based on the text next to the check box, it says that the file will be put through prettify BEFORE saving. If that were truly the case, then this problem wouldn't exist. I suspect that the file is actually being saved BEFORE it goes to the prettifier and there is now a race condition between the prettifier and the compiler.

Hello. Sorry it took so long to get to this.

Well, it is a bit of a lie, that prettifier runs before saving, that much is true.

Reason for that is rather stupid, really. There's no way in Atom API to delay or cancel a file being saved, except for blocking everything in the 'will save' event handler. Which is obviously a bad idea when we're talking about calling out to external binaries -- freezing Atom (including UI) while prettifier does it's job for up to several seconds is obviously a bad UX.

So what it actually does is it re-saves the file after prettifying.

This can and probably does duplicate work, e.g. triggers checks twice, but it shouldn't lead to race conditions, at least as far as I can tell. After all, it's not like hitting ctrl+s twice by accident leads to anything like that?

Actually, it appears that I'm lying as well. Checked the documentation and in newer Atom versions there is indeed a way to delay saving. Well, that should solve it.

Will this delaying mechanism be employed in the next release of ide-haskell?

Already released. Forgot to close.