-
Notifications
You must be signed in to change notification settings - Fork 2
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
Aggressive Autosaving Causes File Reformat #133
Comments
We'll check this out, thanks for the bug report. |
@Kryan90 - I'm not able to reproduce the issue with the steps above. Only when making a change to the open .proto file do I see that all files are auto saved, which triggers the 'Tools -> Actions on Save -> Reformat code' action to run 'go fmt' on the .go files. Can you provide more details on the version of IntelliJ/GoLand you are using, the Buf plugin version, and anything else that might allow me to reproduce the problem on my end? |
buf plugin: 0.1.5 It seems to happen within specific contexts, for example inside a function body or struct definition. I took a short video to demonstrate the behavior Screen.Recording.2023-08-16.at.11.17.22.AM.mov |
@Kryan90 - Thanks for the additional context. I'm able to reproduce the behavior here, but even after some fixes to the plugin to reduce the saved documents to only .proto files, it appears that as part of running a background task there is another location in IntelliJ which triggers a save of all unsaved documents: https://github.com/JetBrains/intellij-community/blob/66b0623ced948ee43cb22e32ecaee1c791b22c1f/platform/configuration-store-impl/src/SaveAndSyncHandlerImpl.kt#L179-L180 Any save triggers the default 'Reformat code' action in Tools -> Actions on Save, which leads to the reformatting. I'll continue to try and find a fix for this issue, however it may be more complex than I initially thought. |
Currently, any editor with a .proto file open will trigger reformatting (even if the .proto file itself isn't changed). This appears to be related to changes in editor focus when background jobs are run. Update the plugin to keep track of a modification count based on the protobuf files in the project in addition to the Buf CLI configuration and plugin configuration. Only run 'buf breaking' and 'buf lint' if the count changes (since changes to non-proto/buf files won't impact the results). This should greatly reduce the times we run background jobs and avoid unnecessary reformatting of non-proto files during editor sessions. Fixes #133.
Currently, any editor with a .proto file open will trigger reformatting (even if the .proto file itself isn't changed). This appears to be related to changes in editor focus when background jobs are run. Update the plugin to keep track of a modification count based on the protobuf files in the project in addition to the Buf CLI configuration and plugin configuration. Only run 'buf breaking' and 'buf lint' if the count changes (since changes to non-proto/buf files won't impact the results). This should greatly reduce the times we run background jobs and avoid unnecessary reformatting of non-proto files during editor sessions. Fixes #133.
@Kryan90 - The behavior should be much improved in version 0.2.1 (available now). There are some cases where you may still see auto-save trigger reformatting of Go code, but it should be much less frequent than before. |
This plugin causes auto-save to trigger immediately after I stop typing when a proto file is open but not in focus
Example:
Have a .go file open, open a .proto file -> split and move right
Add a new line to the .go file, auto-save is triggered and go fmt runs removing the newline
Similar to this issue, but I confirmed it is specifically the buf plugin causing it for me: https://youtrack.jetbrains.com/issue/WEB-54949/auto-save-as-soon-as-stop-typing
The text was updated successfully, but these errors were encountered: