Upgrading from v21 to v25 the vssettings file is ignored

SyntaxEditor for WPF Forum

The latest build of this product (v25.1.0) was released 2 months ago, which was before this thread was created.
Posted 3 days ago by Dirk Zellerfeld
Version: 25.1.0
Platform: .NET 9
Environment: Windows 11 (64-bit)
Avatar

We're currently running v21 and we're currently evaluating v25.1. After upgrading, the colors in vssettings file aren't applied.

//calling this after creating the language and registering all the services
using Stream stream = File.Open(path, FileMode.Open);
AmbientHighlightingStyleRegistry.Instance.ImportHighlightingStyles(stream);
 
It only uses colors we've defined in our ClassificationTypeProvider for example
 
public IClassificationType Comment
{
	get
	{
		if ((this.commentValue == null))
		{
			String key = "Comment";
			this.commentValue = this.registryValue.GetClassificationType(key);
			if ((this.commentValue == null))
			{
				this.commentValue = new ClassificationType(key, "Comment");
				this.registryValue.Register(this.commentValue, new HighlightingStyle(Color.FromArgb(255, 71, 156, 70)));
			}
		}
		return this.commentValue;
	}
}

Even trying to overwrite colors have no effect:

var registry = AmbientHighlightingStyleRegistry.Instance;

var ct = registry.GetClassificationType("Comment");
if (ct != null) {
    var style = new HighlightingStyle(
        Colors.LimeGreen,
        null, null, null,
        ActiproSoftware.Windows.Controls.Rendering.LineKind.None
    );
    registry.Register(ct, style, overwriteExisting: true);
}

 I guess somewhere has been a breaking change?

Comments (4)

Posted 3 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Dirk,

We made some changes in v24 that might be impacting you, especially if you are using a vssettings file just to support dark themes.  If that is the case, please take a look at the v24.1 conversion notes regarding native dark theme support.  We now have a better way to support dark themes without the vssettings file.  More details on dark theme support can be found here.

If this is unrelated to dark themes, is it possible you are loading the vssettings file before the registry and classification types are fully initialized?  Try loading them late in the application startup process to see if that makes an impact.  I do see where you are also trying to customize a color.  Have you verified that the sample for defining the "LimeGreen" color is actually executing that block of code?  I only ask since it is inside an IF block and will only execute if there was not already an existing classification type for a comment.


Actipro Software Support

Posted 2 days ago by Dirk Zellerfeld
Avatar

Thank you, yes it only affects the dark theme. I'm following this suggestion because we have custom keys. Unfortunately this code has also no effect. The key words color doesn't change.

IHighlightingStyleRegistry registry = AmbientHighlightingStyleRegistry.Instance;
registry.DarkColorPalette.SetForeground("Comment", System.Windows.Media.Colors.Yellow);
registry.DarkColorPalette.SetForeground("Number", System.Windows.Media.Colors.Yellow);

This code is applied after ImportHighlightingStyles call (which probably isn't necessary anymore as its ignored), after the language has been created but before any Syntax Editor is visible. Only color changes from our ClassificationTypeProvider are admited.

May I ask why ImportHighlightingStyles is completely ignored? I understand that it isn't necessary anymore but what if we want / need it? Continue making it work wouldn't affect people who are not using this.

Posted 2 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

It is worth noting that changing the color in the color palette does not automatically transfer to any styles that were already configured before the color was changed (as mentioned here).  When the color palette is changed, all highlighting styles are updated with the colors from the new palette, so make sure the dark colors are configured before changing the registry to the dark palette.

We have tested importing highlighting styles locally and it worked as expected.  When you import highlighting styles, any changes in colors are pushed back to the current color palette.  So if you import styles while the light color palette is active and then switch to dark, you wouldn't see a difference in the dark theme.  Importing styles is the same as if the user had customized their colors, and the color for a light theme is typically not what you'd want for a dark theme.  That's why changes are only applied to the active color palette.  If you are importing dark colors, make sure the dark color palette is active before you import.

If any of the suggestions above do not help, there might be something specific about your scenario that is leading to what you are seeing Could you please try to reproduce in a simple sample project and send to our support email so we can investigate in more detail?  If so, please remove any bin/obj folders from the ZIP before sending or the attachment might be blocked.


Actipro Software Support

Posted 3 hours ago by Dirk Zellerfeld
Avatar

Theme is only applied on start of the application. We listen to the CurrentThemeChanged which then creates the language, then imports the vssettings file. This has worked perfectly in v21. In v25, any tries to modify colors after the language has been created doesn't work for dark mode. I just tested light mode and loading vssetting here works fine. Like if I change the colors in the file and launch the app I can see the color changes in the syntax editor. But in dark mode it just doesn't work.

I've created a repro: https://limewire.com/d/vojAg#gogVcMVC5Q

Type anything into the editor and you'll see its yellow because of these lines:

identifierValue = new ClassificationType(key, "Identifier");
registryValue.Register(identifierValue, new HighlightingStyle(Colors.Yellow));

However the vssettings file in bin folder should change the color but its ignored

Add Comment

Please log in to a validated account to post comments.