VSE-FormatDocumentOnSave icon indicating copy to clipboard operation
VSE-FormatDocumentOnSave copied to clipboard

Broken on VS2022 > 17.3.3

Open lucasbenhur opened this issue 3 years ago • 53 comments

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.

lucasbenhur avatar Sep 01 '22 16:09 lucasbenhur

Same

valentasm1 avatar Sep 02 '22 09:09 valentasm1

🤕 Will check it on Monday...

mynkow avatar Sep 02 '22 18:09 mynkow

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.

mynkow avatar Sep 07 '22 09:09 mynkow

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.

valentasm1 avatar Sep 07 '22 09:09 valentasm1

I waited 1-2 min, but it didn't work.

I also tried:

  • Reset visual studio settings.
  • Re-install extension

Unsuccessfully!

lucasbenhur avatar Sep 08 '22 04:09 lucasbenhur

<time>2022/09/09 11:23:12.610</time>
<type>Information</type>
<source>Extension Manager</source>
<description>Successfully loaded extension &apos;Format document on Save&apos; (2f4fac85-be4e-4d7a-8c74-93cc4389b427)...</description>

There is no errors in my logs, but the extension is not working.

lumicompell avatar Sep 09 '22 11:09 lumicompell

Hey, great news. It stopped working for me as well. Just like that. No idea why. It is really...

mynkow avatar Sep 09 '22 12:09 mynkow

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:

image

The Saved boolean is the only indicator to not enter into infinite loop.

mynkow avatar Sep 12 '22 09:09 mynkow

Soo is it end for this extension?

valentasm1 avatar Sep 12 '22 17:09 valentasm1

Did you wrote smth to MS? Now extension works again in 17.3.4 version

valentasm1 avatar Sep 14 '22 10:09 valentasm1

Woooow, this is madness. I am glad they have fixed that.

mynkow avatar Sep 19 '22 06:09 mynkow

It was working. Now it is not again. I think it works sometimes and sometimes not. Anyone else could confirm it works for them?

valentasm1 avatar Sep 19 '22 06:09 valentasm1

It was working after updating to 17.3.4. It is not working after updating winOS and rebooting.

lumicompell avatar Sep 19 '22 07:09 lumicompell

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

mynkow avatar Sep 22 '22 21:09 mynkow

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 avatar Sep 23 '22 07:09 mus65

@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

valentasm1 avatar Sep 23 '22 09:09 valentasm1

Code Cleanup is not working for me.

lumicompell avatar Sep 23 '22 09:09 lumicompell

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)

WolfgangVogl avatar Sep 23 '22 12:09 WolfgangVogl

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 avatar Sep 26 '22 15:09 Krusty93

@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

valentasm1 avatar Sep 26 '22 16:09 valentasm1

I am working on a workaround. ;)

mynkow avatar Sep 27 '22 10:09 mynkow

It seems that extension now work again for VS 17.3.5

Alexolut avatar Sep 28 '22 16:09 Alexolut

It is still not working on my end. This is strange.

mynkow avatar Sep 29 '22 06:09 mynkow

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.

WolfgangVogl avatar Sep 29 '22 06:09 WolfgangVogl

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.

dlehn avatar Sep 29 '22 07:09 dlehn

@WolfgangVogl you can go and disable an extension without uninstalling it. I think it requires a VS restart.

mynkow avatar Sep 29 '22 09:09 mynkow

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.

Elders.VSE_FormatDocumentOnSave.vsix.zip

mynkow avatar Sep 29 '22 09:09 mynkow

I just tried it on 17.3.5 and the formatting works again now. Thanks for the fix!

dlehn avatar Sep 29 '22 09:09 dlehn

Still appears to be broken for me on 17.3.5.

aligature avatar Sep 29 '22 18:09 aligature

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.

Elders.VSE_FormatDocumentOnSave.vsix.zip

I gave this version a try and it seems to be functional based on my spot testing.

aligature avatar Sep 29 '22 18:09 aligature