Posted 4 years ago by Sylko Zschiedrich
Version: 20.1.0401
Avatar

Hi all,

we created a rich set of CodeSnippets for our language pack in our product. 
Now we tried to change the SortOrder in the CodeSnippetSelectionSession because the default sorting is confusing. 

Is there a way to customize this sorting in the CodeSnippetSelectionSession?

Kind regards

Sylko

Comments (4)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

The code snippets should currently be sorting alphabetically by their name.  What kind of different sorting were you looking to achieve?  Also note you can use subfolders to organize snippets too.


Actipro Software Support

Posted 4 years ago by Sylko Zschiedrich
Avatar

Hello,

correct the default sorting is alphabetically. But folders and snippets are mixed und in our case we want to see the most important snippets first.

Thanks

Sylko

[Modified 4 years ago]

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

We are making the following change for the next build 402:

Updated the virtual CodeSnippetSelectionSession.OnCompletionSessionInitializing method to perform sorting and be called after items have been added to the session, so that completion items and/or sorting can be customized prior to opening.

The idea is that you can make a custom class that inherits CodeSnippetSelectionSession and override its OnCompletionSessionInitializing method to call session.SortItems(yourcustomcomparer). 

To get a custom CodeSnippetSelectionSession class in place, you will have to also make a class that inherits CodeSnippetProvider and override the CreateSelectionSession method.  Here's the default implementation:

protected virtual ICodeSnippetSelectionSession CreateSelectionSession(ICodeSnippetFolder rootFolder, CodeSnippetTypes snippetType) {
	var session = new CodeSnippetSelectionSession();
	session.Label = SR.GetString(snippetType == CodeSnippetTypes.SurroundsWith ? 
		SRName.UIIntelliPromptCodeSnippetSelectorSurroundWithText : SRName.UIIntelliPromptCodeSnippetSelectorInsertSnippetText);
	session.RootFolder = rootFolder;
	return session;
}

Your override would need to do the same thing but create your custom CodeSnippetSelectionSession class instead.


Actipro Software Support

Posted 4 years ago by Sylko Zschiedrich
Avatar

Hallo!

Thanks for your answer and support.

I'm looking forward to this next release.

Sylko

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.