nbadal / ktlint-intellij-plugin

Ktlint plugin for IntelliJ IDEA + Android Studio
MIT License
157 stars 23 forks source link

"Format with ktlint" no longer shown as a context option #440

Closed Jolley71717 closed 6 months ago

Jolley71717 commented 8 months ago

It appears that the contextual "Format with ktlint" option has been removed from the list of options. Reviewing the release notes, I don't believe this was intentional.

image

I can reproduce this by opening up a scratch file and adding something like the following with any sort of formatting issue, e.g. ex

val somethingFake = "yeet" 

image

The plugin is enabled and set to Manual mode image

paul-dingemans commented 8 months ago

It has been removed intentionally. Format with ktlint reformats the entire file. From a UX perspective the action in this menu did seem to suggest to format the highlighted issue only. I will think about whether, I want to re-add it with a description that makes clear that the entire file is formatted, for example Format file with ktlint.

Untill then, you can use the Format with ktlint menu option in the Refactor menu. Defining a shortcut on that menu option makes it easily accessible.

alextchatalov commented 7 months ago

It's possible to format only a line or selected code, because some times i don't want to format all file, there are a lot of code and is hard to do the code review. My team is using this plugin now and we don't want to format old code, only new changes.

paul-dingemans commented 7 months ago

It's possible to format only a line or selected code, because some times i don't want to format all file, there are a lot of code and is hard to do the code review. My team is using this plugin now and we don't want to format old code, only new changes.

Ktlint has never supported partial formatting of file. So the old behavior was that the context menu with name "Format with ktlint" suggested that only the particular violation would be formatted. The real behavior was that the entire file was formatted. See #385 for request to support partial formatting.