[PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk
Paul Hoad via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 26 08:39:44 PDT 2015
MyDeveloperDay added a comment.
After a little digging, the problem is based on the fact that the extension doesn't load until we use it, so the nBeforeSave won't fire, so after doing Ctrl-R,Ctrl-F once it will work
This exact same problem is mentioned here
So, we implement all of the event functionality and try out the extension. **The first time we save a file, no arranging happens. If we run the arrange command from the menu item, it runs fine and then subsequent file saves also get arranged. **That seems weird. It turns out that Visual Studio only loads the extensions as needed. We have to add another one of our provide attributes, ProvideAutoLoadAttribute, to the VSPackage class to get the extension to load sooner.
I found the GUID to pass to this from a blog post I found to get the extension to load as soon as possible. After further research on MSDN, it turns out to be the same as the UIContextGuids80.NoSolution field. The remarks seem to indicate that it would only become active when a solution is closed or Visual Studio is started with the "Show Empty Environment" option set in startup; however, it looks like it happens when Visual Studio is started no matter the value of the startup setting. There are other useful contexts in the UIContextGuids80 Class. The attribute can be rewritten as shown.
More information about the cfe-commits