Why is Reformat and Cleanup not reformatting the code?

Completed

Reformatting and Cleanup (ctrl-alt-F) is not reformatting the code. While Reformat Code (ctrl-alt-L) actually does the reformatting but only at the file level.

How does one reformat the code at the folder level? Also, it's not clear what's the difference between the two options I mentioned.

In R# there's one option for code reformatting  (ctrl-alt-F) where one selects the profile AND it does the work. 
Not sure why it's split into two different options in Rider which makes it confusing. Is ctrl-alt-F in Rider just for selecting the profile?

0
5 comments

Hello Abdu,

`Reformat and Cleanup` does reformat the code according to the selected profile. Once you selected the desired profile, you are free to call the separate action `Silent  Reformat and Cleanup` (Ctrl+Alt+Shift+F). It allows you to avoid the profile selection dialog by using the previously selected one. You can find more details here.

`Reformat code` allows to reformat the only opened file. It might be useful in the case of huge solutions, as instead of scanning the whole solution every time `Reformat` is called, the only open file is being reformated.

You might find the recently added feature interesting. You can enable the `Reformat on save` feature from `File | Settings | Tools | Actions on Save`.

 

0

I want to reformat code  for all the files in a folder and its subfolders.

I right click on the top folder and select Reformat and Cleanup and select a profile, hit OK. Nothing happens. I tried all the profiles.I open a file and it's not reformatted. I hit ctrl-alt-L and select Include Subdirectories. The file is still not reformatted. 
I hit ctrl-alt-shift-F on the folder and the file is still not reformatted.

The only way I can reformat the file is to open the file and hit ctrl-alt-L inside it. I don't want to do this for every single file.

How do I reformat all the files in a single action?


0

Apologies for the late reply.

There was an issue, please try updating Rider or try a workaround
There was an issue when the reformatting behavior was broken in some circumstances. It was fixed with Rider 2021.3 EAP7. What version of Rider do you use? (`Help | About`)

If the build number of Rider is less than 213.5605.83, there are two options:

  1. To update Rider to the [latest](https://www.jetbrains.com/rider/download/).

  2. To try a workaround with a sample folder:
  • If the target folder is named with only lower or upper case (`folder`/`FOLDER`), please try renaming it to (`Folder`);
  • Clear the caches `File | Invalidate caches | Turn on all the checkboxes | Invalidate and Restart`
  • Try reformatting this folder via ` Right-click on the folder from Solution Explorer | Reformat and Cleanup | Directory {} | Full Cleanup | Analyze`

If the above instruction does not help
Would you mind trying to execute the following actions:

  • Enable `CodeCleanup` trace scenario via `Help | Diagnostic Tools | Choose Trace Scenario | CodeCleanup`
  • Select the whole solution or the exact project from the `Solution explorer`;
  • Press `Code | Reformat and Cleanup` (right from Rider top menu, not via the shortcut)
  • Select the flag `Solution/Whole solution` or `Project {prj}`;
  • Select the profile `Full Cleanup`; (please make a fullscreen screenshot of Rider at this moment and share it with us);
  • Ensure the issue is reproduced and let me know the exact timestamp.
  • Collect Rider logs via `Help | Collect Logs`;
  • Disable CodeCleanup trace scenario.

Please send the generated archive to us via the Upload Service and let me know the Upload ID.

I will be waiting for your response.

0

It seems to be working now. Thanks.

0

I am happy  I was able to help you.
If you have any questions or difficulties in the future, do not hesitate to contact support.
Have a great day!

0

Please sign in to leave a comment.