icsharpcode / AvalonEdit

The WPF-based text editor component used in SharpDevelop
http://avalonedit.net/
MIT License
1.85k stars 469 forks source link

Overwrite registered highlightings #390

Closed ltrzesniewski closed 1 year ago

ltrzesniewski commented 1 year ago

ILSpy changes themes by calling HighlightingManager.RegisterHighlighting to set the new color scheme: https://github.com/icsharpcode/ILSpy/blob/4ebe075e5859939463ae420446f024f10c3bf077/ILSpy/TextView/DecompilerTextView.cs#L1220-L1226

I noticed that each registered highlighting definition is added to the HighlightingDefinitions collection, and is never removed. Therefore, repeatedly changing the theme in ILSpy creates a small memory leak.

This PR changes this behavior so that registering a named highlighting definition will remove the previous one if it exists.

christophwille commented 1 year ago

Thanks! (reviewed with @siegfriedpammer )