nbadal / ktlint-intellij-plugin

Ktlint plugin for IntelliJ IDEA + Android Studio
MIT License
166 stars 24 forks source link

Format with ktlint in Quick Fixes menu #492

Closed JonZarate closed 7 months ago

JonZarate commented 7 months ago

I remember being able to run the ktlint formatter from the Quick Fixes menu (Alt + Enter | Option + Enter) on code highlighted by the plugin.

I would expect the Manual mode to allow this, but instead I have to (Right click ->) Refactor -> Format with Ktlint.

The new releases seem to be oriented to automating as much as possible, but to me this was a great way of learning as I went through each issue and I would pay close attention to the before and after

Can it be configured to display the option again in Quick Fixes ?

Another option would be to attach the formatter to the Intellij Reformat Code, but not sure it's possible.

Thank you!

paul-dingemans commented 7 months ago

I remember being able to run the ktlint formatter from the Quick Fixes menu (Alt + Enter | Option + Enter) on code highlighted by the plugin.

I would expect the Manual mode to allow this, but instead I have to (Right click ->) Refactor -> Format with Ktlint.

The new releases seem to be oriented to automating as much as possible, but to me this was a great way of learning as I went through each issue and I would pay close attention to the before and after

Can it be configured to display the option again in Quick Fixes ?

This quick fix was removed because it was misleading. As user you would expect that only one particular option would be reformatted when applying the quick fix. But instead, the entire file was reformatted.

It is great that you want to learn as much about the formatting rules as possible. But you can also look at it differently:

Another option would be to attach the formatter to the Intellij Reformat Code, but not sure it's possible.

In manual mode it is not possible to attach the ktlint formatter to Reformat Code as that would change the default behavior of Intellij which is not appreciated by users of the manual mode. What you can do, is reassing the code format shortcut to the Format with Ktlint action.

paul-dingemans commented 7 months ago

Also you might want to follow #482

QuinnBast commented 6 months ago

This quick fix was removed because it was misleading. As user you would expect that only one particular option would be reformatted when applying the quick fix. But instead, the entire file was reformatted.

This did not used to be the case in the unofficial ktlint plugin.

paul-dingemans commented 6 months ago

You're wrong. Ktlint has never supported partial formatting of files. It was just all or nothing.