Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AndroidDeveloperLB opened this issue May 10, 2023 · 10 comments

Comments

@AndroidDeveloperLB
Copy link

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
Copy link
Contributor

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
Copy link
Author

But I want it to auto-save.

@fishermans
Copy link
Contributor

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

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 10, 2023

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

@fishermans
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

fishermans commented May 10, 2023

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 if needed (that's how I do it).
  • Modify the plugin according to your needs
  • Live with the Auto Save formatting

@markiewb
Copy link
Contributor

markiewb commented May 10, 2023 via email

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented May 10, 2023

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants