rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

Reformat "file" action on save doesn't reformat code #677

Open gregbrowndev opened 2 years ago

gregbrowndev commented 2 years ago

Hi there,

Firstly, thanks for this plugin. It is very helpful while learning Haskell.

I'm having difficulty using the plugin to reformat code on save. The issue is very similar to the one posted here: https://github.com/rikvdkleij/intellij-haskell/issues/284.

Just to confirm, I'm on a Mac and I can use the shortcut ⌥ ⌘ L to reformat a code fragment. This works as expected. However, I can't seem to get this to work with Actions on Save feature.

I think the problem is the plugin doesn't appear to have hooked up the Reformat file feature which uses the ⌥ ⇧ ⌘ L shortcut on a Mac. If I use this shortcut, nothing happens. I believe the Actions on Save to "reformat code" actually triggers reformat file rather than reformat code fragment.

image

As you can see in the image above, I also tried creating a File Watcher to run hindent on save. However, that produced undesirable results as the code would reformat as you are typing even with auto-save turned off. I think the issue was described here due to Live Edit triggering auto-save, but I don't know how the OP managed to turn it off. I only mention this as currently I don't have a good solution to reformat on save.