dubreuia / intellij-plugin-save-actions

Supports configurable, Eclipse like, save actions, including "organize imports", "reformat code" and "rearrange code".
MIT License
531 stars 101 forks source link

Request: for "Reformat file" on save, please prevent it in case it changes logic or when the code has errors #430

Open AndroidDeveloperLB opened 1 year ago

AndroidDeveloperLB commented 1 year ago

Describe the solution you'd like

Suppose I have these settings:

image

On Java and especially on Kotlin, when I leave the IDE in the background (pressing Home key, for example), it sometimes auto-formats when it shouldn't.

For example in this case of Kotlin, it's really annoying, as I haven't finished writing what's on the line with the "notificationManager." :

fun foo(context: Context, notification: Notification) {
    val notificationManager = NotificationManagerCompat.from(context)
    notificationManager.
    notificationManager.notify(123, notification)
}

It becomes this way:

fun foo(context: Context, notification: Notification) {
    val notificationManager = NotificationManagerCompat.from(context)
    notificationManager.notificationManager.notify(123, notification)
}

See video:

studio64_2023-05-10_12-21-25.zip

And sample:

My Application.zip

Please have some option to avoid it. Maybe even turn it on by default.

For what product Intellij (Android Studio)

fishermans commented 1 year ago

Turn off auto save in your IDE to prevent reformatting. This plugin is triggered on "save" if the first option is enabled. "Save" means "save" (also auto save).

AndroidDeveloperLB commented 1 year ago

But I want it to auto-save.

fishermans commented 1 year ago

Disable first option and use short cuts (second option). That's how it works.

AndroidDeveloperLB commented 1 year ago

But I want this turned on too. That's one of the reasons I use this plugin...

fishermans commented 1 year ago

See my first answer. If save is triggered, this plugin is doing its job. Feel free to fork it and try to modify it. I am using the short cut option for many years without any issues.

AndroidDeveloperLB commented 1 year ago

I know it's doing its job. It does it well, but when I leave the IDE, I don't want it to do anything, because I'm not ready yet for formatting in case the code gets this way. Sometimes I write something, and go to another window to check what I should write next, and then this happens.

So, my request is to prevent it from happening in such cases.

fishermans commented 1 year ago

I know what you mean but it is triggered by save even if save is triggered in background every 15 sec.. The author of this plugin won't do anything anymore.

There were problems in the past when the plugin was run only in the active window, especially since files can be open in multiple windows at the same time.

Therefore only remains:

markiewb commented 1 year ago

Sorry to interrupt your chat.

Have you noticed that there is an option "No action if compile errors (applied per file)"?!

fishermans @.***> schrieb am Mi., 10. Mai 2023, 13:14:

I know what you mean but it is triggered by save even if save is triggered in background every 15 sec.. The author of this plugin won't do anything anymore.

There were problems in the past when the plugin was run only in the active window, especially since files can be open in multiple windows at the same time.

Therefore only remains:

  • Choose other settings and press three buttons at Befarf (that's how I do it).
  • Modify the plugin according to your needs
  • Live with the Auto Save formatting

— Reply to this email directly, view it on GitHub https://github.com/dubreuia/intellij-plugin-save-actions/issues/430#issuecomment-1541978775, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOFMR6VCCSRI6QFWGBSUD3XFN2ANANCNFSM6AAAAAAX4OPLTI . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

AndroidDeveloperLB commented 1 year ago

@fishermans Are you saying this plugin won't get updated anymore? :(

@markiewb Sadly this setting ("No action if compile errors...") doesn't work for the case I've shown:

    notificationManager.
    notificationManager.notify(123, notification)

Perhaps it's related to the fact that it's Kotlin?

KnoxasKing commented 10 months ago

As @fishermans said, unfortunately this plugin has been abandoned and therefore is incompatible with new versions of the Jetbrains IDEs.

In alternative you can use this fork:

https://plugins.jetbrains.com/plugin/21538-save-actions-tool https://github.com/wanghuan9/intellij-plugin-save-action-tool But for more information check the thread: #427