VSE-FormatDocumentOnSave
VSE-FormatDocumentOnSave copied to clipboard
Broken on VS2022 > 17.3.3
Latest update from VS seems to have broken this extension unfortunately. No longer formatting document when I edit.
My settings are set at the default.
Same
🤕 Will check it on Monday...
Hmm, it is working for me. It just takes 1-2 minutes VS2022 to load all extensions. Once loaded it is working.
Could you please check that? If this is the case we can't do anything. The other options is to take a look at the VS logs and see for errors there.
How to know when extensions is loaded? At first i thought it is resharper but then i disable it and it still dont format on save.
I waited 1-2 min, but it didn't work.
I also tried:
- Reset visual studio settings.
- Re-install extension
Unsuccessfully!
<time>2022/09/09 11:23:12.610</time>
<type>Information</type>
<source>Extension Manager</source>
<description>Successfully loaded extension 'Format document on Save' (2f4fac85-be4e-4d7a-8c74-93cc4389b427)...</description>
There is no errors in my logs, but the extension is not working.
Hey, great news. It stopped working for me as well. Just like that. No idea why. It is really...
Here is what I have found. And I do not think we could fix it at all. When you edit a file and save it, the extension captures the action and formats the document before being saved. This is possible because of the events coming from VS. However, the document is actually saved before throwing the event. See the screenshot bellow:

The Saved boolean is the only indicator to not enter into infinite loop.
Soo is it end for this extension?
Did you wrote smth to MS? Now extension works again in 17.3.4 version
Woooow, this is madness. I am glad they have fixed that.
It was working. Now it is not again. I think it works sometimes and sometimes not. Anyone else could confirm it works for them?
It was working after updating to 17.3.4. It is not working after updating winOS and rebooting.
I have added steps to reproduce to MS. I doubt that they will fix this.
https://developercommunity.visualstudio.com/t/Visual-Studio-clears-dirty-flag-before-c/10124978#T-N10148841-N10155655
We also hit this, but we found an alternative which makes the whole extension obsolete, at least for our use cases. In "Options -> Text Editor -> Code Cleanup" there is an option "Run Code Cleanup profile on save". If you include the fixer "Format document" in the configured profile you basically have the same functionality this extension provides.
@mus65 I dont want be a bummer about this extension but your suggestion is great. I dont need this extension anymore :). I havent heard about it but looks usefull, simple and customizable. I just missing more explanation on some formatting
Code Cleanup is not working for me.
Yes, again - Clang Power Tools (format on save) and this extension (format document on save) no longer work and Code Cleanup doesn't work either. (See https://developercommunity.visualstudio.com/t/Code-Cleanup-Support-for-C/1693911)
We also hit this, but we found an alternative which makes the whole extension obsolete, at least for our use cases. In "Options -> Text Editor -> Code Cleanup" there is an option "Run Code Cleanup profile on save". If you include the fixer "Format document" in the configured profile you basically have the same functionality this extension provides.
Unfortunately, the code clean up setting cannot be synchronized among the team. Instead, this extension can. This makes the difference
@Krusty93 i think sync setting is also doable or at least in close future. Check it out more here https://devblogs.microsoft.com/visualstudio/bringing-code-cleanup-on-save-to-visual-studio-2022-17-1-preview-2/#comment-26451 https://github.com/dotnet/roslyn/issues/40163
I am working on a workaround. ;)
It seems that extension now work again for VS 17.3.5
It is still not working on my end. This is strange.
It is still not working on my end. This is strange.
For me, formatting on save works with the VS Update to 17.3.5. I'm not sure if it is this extension or one of the others (Clang power tools, ...). If you instruct me how to find out which one does the job I would be happy to share this information with you.
I just tested this myself. VS 17.3.5 does not fix the issue, but the Format on Save option of Clang Power Tools 2022 does work. But unfortunately their solution does seem to introduce a noticeable delay when saving as well as an additional undo step (you need to press Ctrl + Z twice after saving if you want to undo the automatic formatting), so it's quite a downgrade from your extension.
@WolfgangVogl you can go and disable an extension without uninstalling it. I think it requires a VS restart.
Hey everyone, I have a workaround implemented in the version attached to this comment. If you think it works properly I will upload it to the extension store. Please give any feedback.
I just tried it on 17.3.5 and the formatting works again now. Thanks for the fix!
Still appears to be broken for me on 17.3.5.
Hey everyone, I have a workaround implemented in the version attached to this comment. If you think it works properly I will upload it to the extension store. Please give any feedback.
I gave this version a try and it seems to be functional based on my spot testing.