I have a language that implements current line highlighting style as shown in the code below taken from my language constructor and this works as expected.
// Create a custom registry
IHighlightingStyleRegistry registry = new HighlightingStyleRegistry();
registry.Description = this.Key;
// hook up current line highlighting to this registry
DisplayItemClassificationTypeProvider providertypes = new DisplayItemClassificationTypeProvider(registry);
providertypes.RegisterAll();
registry.Register(providertypes.CurrentLine, new HighlightingStyle(), false);
When a file of this language type is opened or created the language's HighlightingStyleRegistry is retrieved and assigned to the documents language as shown below. This works as expected.
// Set the language after everything's loaded
ISyntaxLanguage language = this.LanguageManager.LoadLanguage(this.CodeDocumentModel.LanguageKey);
editor.Document.Language = language;
// Get the IHighlightingStyleRegistry for this language.
SyntaxLanguageBase languageBase = language as SyntaxLanguageBase;
editor.HighlightingStyleRegistry = languageBase.GetHighlightingStyleRegistry();
// Set colors from user options
this.UpdateHighlightingStyleRegistryCurrentline(editor);
The user can specify what colors to use for line highlighting and the code for setting those values is shown below.
/// <summary>
/// Update syntax editor <c>IHighlightingStyle</c> property current line highlighting.
/// </summary>
/// <param name="editor">The syntax editor</param>
/// <remarks>Applies to all documents regardless of language type</remarks>
public void UpdateHighlightingStyleRegistryCurrentline(SyntaxEditor editor)
{
IClassificationType type = editor.HighlightingStyleRegistry["CurrentLine"];
IHighlightingStyle highlightingStyle = editor.HighlightingStyleRegistry[type];
highlightingStyle.Background = this.optionsFontsAndColors.CurrentLineHighlightBackground;
highlightingStyle.BorderBrush = this.optionsFontsAndColors.BorderBrush;
}
The code above appears to work as expected, each value assigned is updated accordingly. However, when a document is displayed the current line highlighting appears to be using the default Actipro values, i.e. light grey border and no background color but as soon as I right click in the view to invoke a context menu then left click back into the view the users current line highlighting colors are used. I am not sure what I am missing?