-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add reformat support to Rider #198
Comments
I guess it should be something like:
I will ask colleagues about calling reformat and OptimizeImports simultaneously. Originally posted by @van800 in #18 (comment) |
I just used your examples (needed to retrieve the editor component with Another thing noteworthy is the fact that your example triggers the save action handlers twice, while the version I posted earlier didn't... not sure what causes that though. Another question I have with this solution: it probably doesn't support VCS changed code either... I really hope that JetBrains will just implement the Originally posted by @bobvandevijver in #18 (comment) |
@bobvandevijver I have asked about multiple commands but no workaround for now. Not sure, what do you mean about vcs changed code. If you want to reformat everything in solution, you need to put solutionNode of SolutionExplorer to context like:
Originally posted by @van800 in #18 (comment) |
@van800 To reformat only changed lines according to your VCS (eg. git) (which is one of the options of the Originally posted by @bobvandevijver in #18 (comment) |
(copy pasted issue comments from #18 for clarity) |
So, for now I trimmed the plugin, leaving only the reformat action as suggested by @van800. A second thing I noticed is that after the reformatting action has finished, the file is still marked as modified an therefor not completely saved. Not sure how to fix that. This has probably to do with the fact that the action is scheduled after the save action. Not sure if the plugin behaves the same in the other IDEs, but there I've never noticed that. I won't create a PR with what I have now, as it is nowhere near something that can be used here (as I deleted almost everything else from the code to make it compile and as simple as possible). However, it is available at the Rider support branch in my fork. I attach the build version here, so others can use it when they don't mind the limitation (only reformatting, single file, not saved after reformat): Rider Save Action.zip As I'm nowhere near finishing this functionality, I will also stop trying to fix it for now. Let's see what my ticket at JetBrains brings us. |
That's weird. Right now, the plugin is triggered once per "dirty" file, the file is reformatted in the plugin, then it is saved (almost, see issue down here). It might be a threading issue.
This is a long lasting issue that we are unable the fix right now, see #39.
Thanks a lot for your time! |
It is probably the same issue as triggering "OptimizeImports" and "ReformatCode" at the same time. Only the |
Please consider this code: |
I'm working on #118 right now that might be used for that. Reopen if not enough |
I can trigger the reformat with the following, ugly hack:
This triggers the following logging in the frontend, which is the same when triggered from the menu/shortcut:
It does not play nice with any other action being executed simultaneously (such as "OptimizeImports"), so it is in no way an suitable solution.
So, it looks like the ReSharper action is simply not triggered/created when the
CodeStyleManager
is used. Do we really need to create a ReSharper plugin, which communicates with the frontend? (see https://www.jetbrains.com/help/resharper/sdk/Products/Rider.html). I cannot find really relevant documentation on this issue.There are also some other issues when compiling the plugin with the Rider SDK, mostly missing classes, so I'm not sure if it's even possible to compile the current plugin for Rider. See bobvandevijver@0a1d0af for the classes I needed to remove in order to being able to build for Rider.
Edit: I also created a ticket at JetBrains: https://youtrack.jetbrains.com/issue/RIDER-20225
(btw, if you want to open an another issue for this discussion just let me know)
Originally posted by @bobvandevijver in #18 (comment)
The text was updated successfully, but these errors were encountered: