4
Vote

Snippet Explorer doesn't fetch Custom Snippet Folders

description

See: http://snippetdesigner.codeplex.com/discussions/214187
You can add folders and snippets to Visual Studio over Tools > Code Snippets Manager

I have created snippets with your extension and placed them in a custom folder, which i added to Visual Studio with Code Snippets Manager.

Your SnippetExplorer displayed the snippets just fine after a search, in the Visual Studio session i created them, but i couldn't open them. Got an error message.

However after a restart of Visual Studio, your SnippetExplorer doesn't find my snippets in the custom folder at all.

The custom folders are stored in the registry at this location:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Languages\CodeExpansions\

There are multiple entries for each coding language, each entry has a path folder containing a key with the name of the language and the value containing a string with all paths including custom paths seperated by ';'



Example:

Visual C#\Paths\

Key: Microsoft Visual CSharp

Value: Path;Path;...

comments

mmanela wrote Apr 3, 2012 at 4:28 PM

This may be a bug in Snippet Designer but there should be a simple workaround for it. Currently, the Snippet Designer does read those registery settings where VS stores its Snippet Directories however it seems to only do this the first time the plugin is ever loaded. After that is saves those initial values and doesn't update it. This means that if you add a new directory using "Tools > Code Snippets Manager" the Snippet Designer might not pick it up. I will look into to fixing this but in the meanwhile you can add your new folder to the Snippet Designers folder list under Tools > Options > Snippet Designer > Indexed Snippet Directories".



Let me know if this helps.





-Matt

Noize wrote Apr 3, 2012 at 7:28 PM

Ah. yeah that fixed it. It's actually ok to stay like this, you dont add snippet folders on a daily basis anyways.
Though it should be mentioned somewhere that u need to/can add directories if u added them after installing the addin.

unr8d wrote May 23, 2012 at 12:12 AM

I have the same issue here. I have a custom folder which stores our snippets. But the work-around sugested above does not work. I have included the custom folder location in "Indexed Snippet Directories", but am enable to insert snippets as VS2010 doesn't find the custom location and give me the option to select it.
Registry entry I added is always deleted/removed as soon as VS app is restarted.
So I can't use the custom snippets. Any solution for this?

mmanela wrote May 23, 2012 at 3:41 PM

@unr8d

Did you also add your new folder to the Code Snippets Manager (Tools > Code Snippets Manager)?

unr8d wrote May 24, 2012 at 1:30 AM

@mmanela
Yes I did. I added the new custom folder location via "Tools > Code Snippets Manager" as well as "Tools > Options > Snippet Designer > Indexed Snippet Directories".
I also registered the new entry for the custom folder in registry. But that got cleared/removed as soon as I restarted VS

mmanela wrote May 24, 2012 at 4:09 PM

That is odd. This seems less a bug with the Snippet Designer and more of a VS issue.